How to parse JSON from a URL with PHP -


i have url:

http://server.com/api.php?results  {"name":"pit, loka","current":{"item":"16","test":"test","test":"84","test":"ok"}} 

i guess php example is:

<?php $file = file_get_contents("http://server.com/api.php?results=item"); $data = json_decode($file); print_r($data); ?> 

but can't results.
how can solve problem?

<?php $file = file_get_contents("http://server.com/api.php?results=item"); $data = json_decode($file);  $name = $data->name; // "name":"pit, loka" $current = $data->current->item; //"current":{"item":"16","test":"test","test":"84","test":"ok"}  foreach ($current $currentx) {     echo $currentx->item; } ?> 

it should work... please test.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -