elize elize - 1 year ago 83
JSON Question

json to array in php index error

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
But I get index error.

what is my wrong?

Answer Source

json_encode() - change an array to the json

json_decode() - change json to the array/object

You should use json_decode.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download