function str_ends_with($str, $end, $ignore_case = false)
{
    if ($ignore_case) {
        $str = str_upper($str);
        $end = str_upper($end);
    }
    if (!strlen($str) && !strlen($end)) {
        return true;
    }
    if (!strlen($end)) {
        trigger_error('str_ends_with() failed, end arg cannot be empty', E_USER_ERROR);
    }
    if (strlen($end) > strlen($str)) {
        return false;
    }
    return str_starts_with(strrev($str), strrev($end));
    return true;
}
    echo json_encode($placeName);
} else {
    if (!empty($_GET['postcode']) || !empty($_GET['search'])) {
        $options = array("format=json", "accept-language=en-gb,en", "countrycodes=gb");
        // 	if (!empty($_GET['scope']))
        // 	{
        // 		if ($_GET['scope'] == $scopeSheffield)
        // 			$viewbox = array('l'=>-1.6, 't'=>53.45, 'r'=>-1.3, 'b'=>53.3);
        // 		else if ($_GET['scope'] == $scopeGeneralArea)
        // 			$viewbox = array('l'=>-2.1, 't'=>53.6, 'r'=>-1.2, 'b'=>53.0);
        //
        // 		$options[] = "viewbox=".implode(",", $viewbox);
        // 	}
        if (!empty($_GET['postcode'])) {
            // Strip spaces and validate
            $postcode = str_upper(str_replace(" ", "", $_GET['postcode']));
            if (!preg_match("/^[A-Z]{1,2}[0-9]{1,2}[A-Z]?[0-9][A-Z^CIKMOV]{2}\$/", $postcode)) {
                throw new InvalidArgumentException("Invalid postcode");
            }
            $options[] = "postalcode=" . $postcode;
        } else {
            // Strip out any dangerous things
            // Only rawurlencode seems to encode things in the way Nominatim likes them
            $search = rawurlencode(strip_tags($_GET['search']));
        }
        // Send the request to Nominatim
        $curl = curl_init("http://nominatim.openstreetmap.org/search/" . $search . "?" . implode("&", $options));
        curl_setopt($curl, CURLOPT_USERAGENT, "Sheffield Walking Group - admin contact tech@sheffieldwalkinggroup.org.uk");
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        $res = curl_exec($curl);
        // Pass the results back unedited