0

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.

1
  • 4
    $array = json_decode($data, true) Commented Mar 26, 2014 at 20:03

1 Answer 1

1

That is JSON. Just use json_decode:

$array = json_decode($data, true);
print_r($array);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.