如何将一维数组转换成PHP对象?
- 内容介绍
- 文章标签
- 相关推荐
本文共计503个文字,预计阅读时间需要3分钟。
两种方法:1. 使用`(Object)`$arr语句强制类型转换;2. 使用`json_decode(json_encode($arr))`语句,通过`json_encode`将数组转换为JSON数据,再通过`json_decode`将JSON数据转换回对象。操作环境:win
两种方法:1、使用“(Object)$arr”语句强制转换;2、用“json_decode(json_encode($arr))”语句,通过json_encode将数组转成JSON数据,再通过json_decode将JSON数据转换成对象。
本文共计503个文字,预计阅读时间需要3分钟。
两种方法:1. 使用`(Object)`$arr语句强制类型转换;2. 使用`json_decode(json_encode($arr))`语句,通过`json_encode`将数组转换为JSON数据,再通过`json_decode`将JSON数据转换回对象。操作环境:win
两种方法:1、使用“(Object)$arr”语句强制转换;2、用“json_decode(json_encode($arr))”语句,通过json_encode将数组转成JSON数据,再通过json_decode将JSON数据转换成对象。

