Saturday, 15 February 2014

php - json_decode to array -



php - json_decode to array -

i trying decode json string array next error.

fatal error: cannot utilize object of type stdclass array in c:\wamp\www\temp\asklaila.php on line 6

here code:

<?php $json_string = 'http://www.domain.com/jsondata.json'; $jsondata = file_get_contents($json_string); $obj = json_decode($jsondata); print_r($obj['result']); ?>

as per the documentation, need specify if want associative array instead of object json_decode, code:

json_decode($jsondata, true);

php json

No comments:

Post a Comment