I have a php string $data
.
on echo $data;
I get
我有一个PHP字符串$ data。关于echo $ data;我明白了
{"_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.
我试过$ data = array($ data);但得到了数组([0] => {“_ index”:“电影”,“_类型”:“电影”,“_ id”:“4”,“_版”:10,“创建”:false})如何正确获取数组。
1 个解决方案
#1
1
That is JSON. Just use json_decode
:
那是JSON。只需使用json_decode:
$array = json_decode($data, true);
print_r($array);
#1
1
That is JSON. Just use json_decode
:
那是JSON。只需使用json_decode:
$array = json_decode($data, true);
print_r($array);