I have the following code. I am trying to get just the name of the city out of the feed that is requested, and into a new array. Can anyone give me an indication.
$city = $_GET['city'];
$json = @file_get_contents('http://ws.geonames.org/searchJSON?country=GB&maxRows=10&name_startsWith=$city');
$json = utf8_encode($json);
$city_suggest = json_decode($json, true);
foreach($city_suggest['geonames'] as $city){
$cities = $city['geonames']['name'];
}
print_r ($cities);
Edit - 1 line of the json response
{"totalResultsCount":323,"geonames":[{"countryName":"United Kingdom","adminCode1":"ENG","fclName":"city, village,...","countryCode":"GB","lng":-0.12883186340332,"fcodeName":"capital of a political entity","toponymName":"London","fcl":"P","name":"London","fcode":"PPLC","geonameId":2643743,"lat":51.5005149421307,"adminName1":"England","population":7556900},
Edit - response of var_dump
array(2) { ["totalResultsCount"]=> int(0) ["geonames"]=> array(0) { } }