PHPjson转数组返回NULL
小郝的分享
2022年08月18日 21:26

PHPjson转数组返回NULL

1.html_entity_decode函数是 把 HTML 实体转换为字符,引号字符转为引号

2.json_encode 转为数组

$lists = json_decode(html_entity_decode($list));

foreach ($lists as $key => $value) {

   $value = json_decode(json_encode($value), true);

}

1示例:

Array

(

    [0] => stdClass Object

        (

            [title] => 标题:

            [type] => 1

            [images] => 

            [remark] => 333

        )

    [1] => stdClass Object

        (

            [title] => 标题:

            [type] => 2

            [remark] => 123

        )

)

2示例

Array

(

    [title] => 标题 :

    [type] => 1

    [images] => 

    [remark] => 333

)