-1

我试图从 foreach 循环创建简单的数组

function ptd_get_taxanomies(){
            foreach ($ptd_taxs as $ptd_tax) {
                $taxon_arg[] = array(
                    'taxonomy' =>$ptd_tax->taxonomy,
                    'field' => 'id',
                    'terms' => $values
                );
            }
    return $taxon_arg;
}

,但它返回给我多维数组,

    Array
(
    [0] => Array
        (
            [taxonomy] => application
            [field] => id
            [terms] => 8

        )

    [1] => Array
    (
        [taxonomy] => dimension
        [field] => id
        [terms] => 4

    )

);

但这不是我想要的,我需要这样的输出 >

   array(
    'taxonomy' => 'application',
    'field' => 'id',
    'terms' => '8',
   ),
   array(
    'taxonomy' => 'dimension',
    'field' => 'id',
    'terms' => '4',
  )

我如何删除第一级数组并获得如上所示的输出

4

2 回答 2

3
function ptd_get_taxanomies(){
    foreach ($ptd_taxs as $ptd_tax) {
        $taxon_arg = $ptd_tax;            
    }
    return $taxon_arg;
}
于 2012-08-28T12:31:13.337 回答
0

只是循环结果?

$taxon_arg =ptd_get_taxanomies();

foreach($taxon_arg as $arg){
    var_dump($arg);
}
于 2012-08-28T12:10:35.420 回答