title: getting an array of cities out of a json response
body: <p>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.</p>
  
  <pre><code>    $city = $_GET['city'];
  $json = @file_get_contents('http://ws.geonames.org/searchJSON?country=GB&amp;maxRows=10&amp;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);
  </code></pre>
  
  <p>Edit - 1 line of the json response</p>
  
  <pre><code>{"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},
  </code></pre>
  
  <p>Edit - response of var_dump</p>
  
  <pre><code>array(2) { ["totalResultsCount"]=&gt;  int(0) ["geonames"]=&gt;  array(0) { } } 
  </code></pre>