/** * * 象转换成数组 * @param $object 将要转换的对象 * @return Array */ function objectToArray($object) { $result = array (); $object = is_object ( $object ) ? get_object_vars ( $object ) : $object; foreach ( $object as $key => $val ) { $val = (is_object ( $val ) || is_array ( $val )) ? objectToArray ( $val ) : $val; $result [$key] = $val; } return $result; }