[英]PHP Multi Dimensional Array Extract
我试图从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',
)
我如何删除第一级数组并获得如上所述的输出
function ptd_get_taxanomies(){
foreach ($ptd_taxs as $ptd_tax) {
$taxon_arg = $ptd_tax;
}
return $taxon_arg;
}
只是循环浏览结果?
$taxon_arg =ptd_get_taxanomies();
foreach($taxon_arg as $arg){
var_dump($arg);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.