Il giorno 08 maggio 2013 10:48, pjhooker <[email protected]> ha scritto:
> ... ho modificato agiungendo isset ... > > --------------------------------------- > <?php > $url=" > http://overpass-api.de/api/interpreter?data=[out:json];node(45.59374,8.92399,45.60718,8.94424);out > ;"; > $json = file_get_contents($url); $data = json_decode($json, TRUE); > > foreach($data['elements'] as $obj) { > if (isset($obj['tags'])) { > $lat=$obj['lat']; > $lon=$obj['lon']; > > foreach($obj['tags'] as $obj1) { > if (isset($obj1['wikipedia'])) { > echo "lat:$lat; lon:$lon; "; > echo $obj1['wikipedia']; > echo "<br>"; > } > else {} > } > } > else {} > } > > ?> > --------------------------------------- > Funziona il primo for each, ma il secondo รจ come se mi restituisce la prima > lettera e poi di tutti i tag, non solo quello con 'wikipedia' > > se provo a mettere al posto di echo $obj1['wikipedia']; solo echo $obj1; mi > restituisce tutti i valori del tag completi ... > > l'esempio col codice aggiornato: > http://host.logosloci.com/test/parse_json.php > <http://host.logosloci.com/test/parse_json.php> > > > KISS $json = file_get_contents($url); $data = json_decode($json, TRUE); foreach($data['elements'] as $obj) { if (isset($obj['tags']["wikipedia"])) { $lat=$obj['lat']; $lon=$obj['lon']; echo "lat:$lat; lon:$lon; "; echo $obj['tags']["wikipedia"]; echo "<br/>"; } else {} } PS Ti conviene salvarti il json in locale invece che fare una richiesta ogni volta mentre debugghi ;) > > -- > View this message in context: > http://gis.19327.n5.nabble.com/Caricare-info-node-OSM-direttamente-su-OpenLayers-tp5759882p5760118.html > Sent from the Italy General mailing list archive at Nabble.com. > > _______________________________________________ > Talk-it mailing list > [email protected] > http://lists.openstreetmap.org/listinfo/talk-it >
_______________________________________________ Talk-it mailing list [email protected] http://lists.openstreetmap.org/listinfo/talk-it

