Monday, September 30, 2013

Json_decode Error: Cannot use object of type stdClass as array

Oops.. I found this Fatal error: Cannot use object of type stdClass as array in /home/username/html/index.php on line 13 when using json_decode() function. How to fix this?

Simply add true parameter. This will solve the problem:

$row = json_decode( $json_data, true );

// now you can use $row as array

echo $row['name'];

No comments :

Post a Comment