-1
我尝试创建foreach循环简单数组PHP多维数组提取
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',
)
我该如何删除第一级阵列并得到如上所述的输出
这就是你的本事。你有两个数组,你想返回。你只能返回一个值,所以你必须返回一个包含这些数组的数组。这就是它的工作原理。 – lonesomeday
第二个也是2维数组,你离开的只是你输出中的周围块。否则,你能否澄清你想达到的目标(完成)? – Styxxy