对象转换为数组
1 function object_to_array($obj){ 2 $obj = (array)$obj; 3 foreach ($obj as $k => $v) { 4 if (gettype($v) == 'resource') { 5 return; 6 } 7 if (gettype($v) == 'object' || gettype($v) == 'array') { 8 $obj[$k] = (array)$this->object_to_array($v); 9 } 10 } 11 return $obj; 12 }