Parse JSON string contents into PHP Array

$obj=json_decode($json);  
echo $obj->id; //prints 1  
echo $obj->name; //prints foo

To put this an array just do something like this

$arr = array($obj->id, $obj->name, $obj->email);

Now you can use this like

$arr[0] // prints 1

It can be done with json_decode(), be sure to set the second argument to true because you want an array rather than an object.

$array = json_decode($json, true); // decode json

Outputs:

Array
(
    [id] => 1
    [name] => foo
    [email] => [email protected]
)

Try json_decode:

$array = json_decode('{"id":1,"name":"foo","email":"[email protected]"}', true);
//$array['id'] == 1
//$array['name'] == "foo"
//$array['email'] == "[email protected]"

Tags:

Php

Json