I have a json text like this:
$text ='{"id":"12","count":"1","1":{"gkey":"g_c5218"},"0":{"gkey":"g_4b4c6"}}';
I want convert it to array:
$arr = json_encode($text,true);
Now I want call $arr['id']
But I get index error.
what is my wrong?
json_encode()
- change an array to the json
json_decode()
- change json to the array/object
You should use json_decode
.