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

前端 未结 4 1489
佛祖请我去吃肉
佛祖请我去吃肉 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:15

    @Gordon seems correct - that looks like JSON. Assuming, though, that you're dealing with an "actual" PHP Object, then it will be iterable; simply run through it with a foreach and push each key/value pair into your destination array.

提交回复
热议问题