手机
当前位置:查字典教程网 >编程开发 >php教程 >PHP中把对象转换为关联数组代码分享
PHP中把对象转换为关联数组代码分享
摘要:/***对象转关联数组*@author*@paramobject$obj*@returnarray*/functionobject_to_a...

/**

* 对象转关联数组

* @author

* @param object $obj

* @return array

*/

function object_to_array($obj){

$_arr = is_object($obj) ? get_object_vars($obj) : $obj;

foreach ($_arr as $key = $val){

$val = (is_array($val) || is_object($val)) ? $this-object_to_array($val) : $val;

$arr[$key] = $val;

}

return $arr;

}

【PHP中把对象转换为关联数组代码分享】相关文章:

PHP设计模式之装饰者模式代码实例

php操作memcache缓存方法分享

PHP cURL初始化和执行方法入门级代码

我的论坛源代码(八)

php curl 上传文件代码实例

我的论坛源代码(二)

PHP面向对象之后期静态绑定功能介绍

一段php加密解密的代码

PHP滚动日志的代码实现

PHP的面向对象编程

精品推荐
分类导航