时间:2021-07-01 10:21:17 帮助过:4人阅读
1.下面是对象转成数组的代码:
public static function object2array($d) { if (is_object($d)) $d = get_object_vars($d); if (is_array($d)) return array_map('self::object2array', $d); else return $d; }
public static function array2object($d) { if (is_array($d)) return (object) array_map('self::array2object', $d); else return $d; }
http://www.bkjia.com/PHPjc/953330.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/953330.htmlTechArticlephp对象转成数组和数组转成对象操作 1.下面是对象转成数组的代码: public static function object2array($d){if (is_object($d)) $d = get_object_vars($d);if (i...