@ 2018-06-22T00:38:55Z <?php
$doc=<<<EOT
{
"status":"ok",
"items":[
{
"location":{
"name":"South Korea",
"address":"",
"lat":36,
"lng":128,
"pk":"108278619196284"
}
},
{
"location":{
"name":"Seoul, South Korea",
"address":"",
"lat":37.5689,
"lng":126.977,
"pk":"110272918995512"
}
},
{
"location":{
"name":"Seoul, Korea",
"address":"",
"lat":37.51502,
"lng":127.01648,
"pk":"108259475871818"
}
},
{
"location":{
"name":"Busan, South Korea",
"address":"",
"lat":35.1796,
"lng":129.076,
"pk":"110643562296368"
}
},
{
"location":{
"name":"Gwangju, South Korea",
"address":"",
"lat":35.1547,
"lng":126.916,
"pk":"146676562016844"
}
},
{
"location":{
"name":"Daegu, South Korea",
"address":"",
"lat":35.8223,
"lng":128.6115,
"pk":"102159636493202"
}
},
{
"location":{
"name":"Gangwon-do, South Korea",
"address":"",
"lat":37.7448241535,
"lng":128.230475313,
"pk":"140680839290948"
}
},
{
"location":{
"name":"HelloKittycafe_sinchon",
"address":"\uc11c\ub300\ubb38\uad6c \uba85\ubb3c\uae3836-6",
"lat":37.5513676016,
"lng":126.922082621,
"pk":"1485147221780322"
}
},
{
"location":{
"name":"\uc5d0\ubc84\ub79c\ub4dc (withEverland)",
"address":"\uacbd\uae30\ub3c4 \uc6a9\uc778\uc2dc \ucc98\uc778\uad6c \ud3ec\uace1\uc74d \uc5d0\ubc84\ub79c\ub4dc\ub85c 199, \uacbd\uae30\ub3c4 \uc6a9\uc778",
"lat":37.2928590281,
"lng":127.203179318,
"pk":"182698125088068"
}
},
{
"location":{
"name":"\ub3d9\ub300\ubb38\ub514\uc790\uc778\ud50c\ub77c\uc790 DDP",
"address":"\uc911\uad6c \uc744\uc9c0\ub85c 281, \uc11c\uc6b8",
"lat":37.5670904054,
"lng":127.009630198,
"pk":"124772757536805"
}
},
{
"location":{
"name":"Gwangju",
"address":"",
"lat":35.159494,
"lng":126.851287,
"pk":"103826889656659"
}
}
]
}
EOT;
$location = [];
$doc = json_decode($doc);
foreach($doc->items as $item) {
if (isset($item->location)) {
echo "location: {$item->location}\n";
}
}
unset($item);
var_dump($doc);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 Fatal error: Uncaught Error: Object of class stdClass could not be converted to string in /in/5PDDU:114
Stack trace:
#0 {main}
thrown in /in/5PDDU on line 114
Process exited with code 255 . Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Fatal error: Uncaught Error: Object of class stdClass could not be converted to string in /in/5PDDU:114
Stack trace:
#0 {main}
thrown in /in/5PDDU on line 114
Process exited with code 255 . Output for 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 Recoverable fatal error: Object of class stdClass could not be converted to string in /in/5PDDU on line 114
Process exited with code 255 . Output for 5.6.0 - 5.6.40 , 7.0.0 - 7.0.33 Catchable fatal error: Object of class stdClass could not be converted to string in /in/5PDDU on line 114
Process exited with code 255 . preferences:dark mode live preview
247.14 ms | 402 KiB | 284 Q