I have a curl command which outputs the following:
"{"meta":{"code":200},"data":{"username":"monstore","bio":"Art clothing line with our life scary tales as the imagination. info@heymonstore.com \/ +6281213162069 \/ BB PIN 293A4565","website":"http:\/\/www.heymonstore.com","profile_picture":"http:\/\/images.ak.instagram.com\/profiles\/profile_4472462_75sq_1354349840.jpg","full_name":"Monstore","counts":{"media":547,"followed_by":6472,"follows":129},"id":"4472462"}}"
Here's the curl command:
$output = curl_exec($ch);
Basically the above is what $output prints out. So I tried to decode this by doing:
$userinfo = json_decode($output, false);
however it returns an empty array. Any idea why?
$userinfo = json_decode($output, true);
you need to specify you want an associative array instead of an object from json_decode:
$userinfo = json_decode($output, true); //could you set this to true and try? It worked for me.
From http://php.net/manual/en/function.json-decode.php, When TRUE, returned objects will be converted into associative arrays.