0

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?

elize
  • 435
  • 1
  • 8
  • 19

1 Answers1

2

json_encode() - change an array to the json

json_decode() - change json to the array/object

You should use json_decode.

Piotr Olaszewski
  • 6,017
  • 5
  • 38
  • 65