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);
本文介绍了一种在PHP中将对象转换为数组的方法,通过递归函数实现,同时提供了使用json_decode函数处理JSON字符串的技巧。
527

被折叠的 条评论
为什么被折叠?



