LMSouq
php-dev Open

Use json_decode() to create array insead of an object

HA
Harsha M V
1 month ago
3 views
Problem Description
I am trying to decode a JSON string into an array but i get the following error. > Fatal error: Cannot use object of type stdClass as array Here is the code: $json_string = 'http://www.example.com/jsondata.json'; $jsondata = file_get_contents($json_string); $obj = json_decode($jsondata); print_r($obj['Result']);

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base