Possible Duplicate:
Fatal error: Cannot use object of type stdClass as array in
Please I keep getting this error: Fatal error: Cannot use object of type stdClass as array in C:\XAMMP\xampp\htdocs\Yemi\geograph\table.php on line 31
This is the php I am trying to run:
You are actually trying to access the object as array.
I can guess you are having problem when you are using json_decode
which is returning an object and inside the foreach
loop you are trying to access it like an associative array.
Passing the second argument as true
to json_decode
force it to return associative array.
Make the below change.
Change your this code line
$items = json_decode($contents);
To
$items = json_decode($contents, true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With