I have a php string $data
.
on echo $data;
I get
{"_index":"movies","_type":"movie","_id":"4","_version":10,"created":false}
I want the string to split in array. So that,
$data["_index"]=movies etc.
I tried $data=array($data);
but got Array ( [0] => {"_index":"movies","_type":"movie","_id":"4","_version":10,"created":false} )
How to correctly obtain array.
That is JSON. Just use json_decode
:
$array = json_decode($data, true);
print_r($array);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.