https://www.cnblogs.com/52php/p/5669594.html
object 转 array
1 2 3 4 5 6 7 8 9 10 11 12 |
|
如果是个 json字符串 的话,可直接通过 json_decode 函数将字符串转换成 object 或 array 。
json_decode 官方手册
(PHP 5 >= 5.2.0, PECL json >= 1.2.0)
json_decode — 接受一个 JSON 格式的字符串并且把它转换为 PHP 变量
mixed json_decode ( string $json [, bool $assoc ] )
参数:
json 待解码的 json string 格式的字符串。
assoc 当该参数为 TRUE 时,将返回 array 而非 object 。
通常是用它来转换成PHP数组,如 $arr = json_decode($josnStr, true);