I am trying to parse a string in JSON, but not sure how to go about this. This is an example of the string I am trying to parse into a PHP array.
$json = \'{
You can use json_decode()
$json = '{"id":1,"name":"foo","email":"foo@test.com"}';
$object = json_decode($json);
Output:
{#775 ▼
+"id": 1
+"name": "foo"
+"email": "foo@test.com"
}
How to use: $object->id //1
$array = json_decode($json, true /*[bool $assoc = false]*/);
Output:
array:3 [▼
"id" => 1
"name" => "foo"
"email" => "foo@test.com"
]
How to use: $array['id'] //1