Answer the question
In order to leave comments, you need to log in
How to create an array from a json array, not an object?
Code:
result:
The situation is that if you then give this string to json_decode, you will get an object, not an array.
I know that json_encode takes 3 parameters and the second one is options. Maybe something can be passed to the second parameter so that json_decode then returns the original array, and not the object? var_dump(json_encode(array("a"=>"b","c"=>"d")));
string(17) "{"a":"b","c":"d"}"
Answer the question
In order to leave comments, you need to log in
found the answer:
We create everything the same way: $a = json_encode(array("a"=>"b","c"=>"d"));
Back to the array like this json_decode($a,true);// i.e. set the second parameter to true
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question