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 = '{"id":1,"name":"foo","email":"[email protected]"}';
Is there some library that can take the id, name, and email and put it into an array?
It can be done with
json_decode()
, be sure to set the second argument totrue
because you want an array rather than an object.Outputs: