Parse JSON string contents into PHP Array

前端 未结 4 1784
孤街浪徒
孤街浪徒 2020-11-29 10:31

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 = \'{         


        
4条回答
  •  旧时难觅i
    2020-11-29 11:02

    Try json_decode:

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

提交回复
热议问题