PHP中stdClass Object转array方法

1.库函数get_object_vars

2.$data = json_decode(json_encode($data),true);

3.函数递归解析:

function objectToArray($array) {
  if(is_object($array)) {
    $array = (array)$array;
  } if(is_array($array)) {
    foreach($array as $key=>$value) {
      $array[$key] = objectToArray($value);
    }
  }
  return $array;
}