<?php
//phpinfo();
$obj = (object)[];
//print_r($obj);die;
$obj->name = 'summer';
$obj->age = '11';
$obj->sex = '女';
$_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;
//get_object_vars — 返回由对象属性组成的关联数组
php 对象转数组
最新推荐文章于 2021-07-25 21:12:37 发布