How to convert a JSON string into an array (PHP)?

前端 未结 4 1529
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-14 17:55

using the below code for decoding json

$categories = json_decode($data);
$categories = $categories->data;

where i get this



        
4条回答
  •  长情又很酷
    2021-01-14 18:25

    Erm, you can just set the 2nd parameter to convert JSON into an array instead of into an object:

    $categories = json_decode($data, true);
    

提交回复
热议问题