Php 类型将多维对象数组强制转换为多维数组

Php 类型将多维对象数组强制转换为多维数组,php,arrays,multidimensional-array,Php,Arrays,Multidimensional Array,我从函数返回了以下对象 stdClass::__set_state(array( 0 => stdClass::__set_state(array( 'term_id' => '175', 'name' => 'a term', 'slug' => 'a-term', 'term_group' => '0', 'term_taxonomy_id' => '177', 'taxonomy'

我从函数返回了以下对象

stdClass::__set_state(array(
   0 => 
  stdClass::__set_state(array(
     'term_id' => '175',
     'name' => 'a term',
     'slug' => 'a-term',
     'term_group' => '0',
     'term_taxonomy_id' => '177',
     'taxonomy' => 'category',
     'description' => '',
     'parent' => '174',
     'count' => '1',
  )),
   1 => 
  stdClass::__set_state(array(
     'term_id' => '182',
     'name' => 'aciform',
     'slug' => 'aciform',
     'term_group' => '0',
     'term_taxonomy_id' => '184',
     'taxonomy' => 'category',
     'description' => '',
     'parent' => '0',
     'count' => '1',
  )),
))
如果我将其强制转换为一个数组,我会得到以下结果

array (
  0 => 
  stdClass::__set_state(array(
     'term_id' => '175',
     'name' => 'a term',
     'slug' => 'a-term',
     'term_group' => '0',
     'term_taxonomy_id' => '177',
     'taxonomy' => 'category',
     'description' => '',
     'parent' => '174',
     'count' => '1',
  )),
  1 => 
  stdClass::__set_state(array(
     'term_id' => '182',
     'name' => 'aciform',
     'slug' => 'aciform',
     'term_group' => '0',
     'term_taxonomy_id' => '184',
     'taxonomy' => 'category',
     'description' => '',
     'parent' => '0',
     'count' => '1',
  )),
)
问题是,我还需要将内部对象类型转换为数组。我可以通过使用一个
foreach
循环来实现这一点,然后将每个值都强制转换到一个数组中,并在此基础上构建一个新数组,比如

foreach ($a as $b) {
    $c[] = (array) $b;
}
?><pre><?php var_dump($c); ?></pre><?php    
我的PHP知识仍然非常有限,我需要知道的是,是否有其他更短更好的方法来实现这一点,或者这是唯一的方法

额外背景
  • 不幸的是,我无法更改函数的输出。这是Wordpress中的一个函数,它只返回一个对象对象,没有返回一个值数组的选项

  • 我需要搜索特定的
    术语\u id
    ,并返回其位置。同样,我可以使用一个
    foreach
    循环来实现这一点,但是PHP5.5+有一个函数
    array\u column
    ,您可以使用
    array\u search
    在多维数组中搜索特定值(在本例中为
    term\u id
    ),并返回该特定数组的键


    • 我使用
      json\u编码
      json\u解码

      $array = json_decode(json_encode($object), true);
      
      或者一下子:


      它非常快速,适用于所有维度。

      我使用
      json\u编码
      json\u解码

      $array = json_decode(json_encode($object), true);
      
      或者一下子:


      它速度很快,适用于所有尺寸。

      太好了,我没有想到这一点。将需要研究这些函数,但没有考虑到这一点。我们需要研究这些功能
      $array = json_decode(json_encode($object), true);