PHP–JSON object to array
The trick was to pass in ‘true’ to the json_decode.. This returns an associative array instead of an object.
$json_string = 'https://example.com/jsondata.json';
$jsondata = file_get_contents($json_string);
$obj = json_decode($jsondata,true);
echo ‘<pre>’;
print_r($obj);
Leave a Reply