我需要导航这个数组
Array
(
[0] => Array
(
[isComplex] => 1
[condition] => and
[predicates] => Array
(
[0] => Array
(
[isComplex] => 1
[condition] => and
[predicates] => Array
(
[0] => Array
(
[isComplex] => 1
[condition] => and
[predicates] => Array
(
[0] => Array
(
[isComplex] =>
[field] => NAME
[operator] => startswith
[value] => as
[ignoreCase] => 1
)
[1] => Array
(
[isComplex] =>
[field] => MAIN_PHONE
[operator] => startswith
[value] => 06
[ignoreCase] => 1
)
)
)
[1] => Array
(
[isComplex] =>
[field] => COD_FISC
[operator] => startswith
[value] => 98
[ignoreCase] => 1
)
//array multi
)
)
[1] => Array
(
[isComplex] =>
[field] => id
[operator] => startswith
[value] => 12
[ignoreCase] => 1
)
)
)
)
我想要获得的结果是只有具有键字段
的数组居: 结果:
[0] => Array
(
[isComplex] =>
[field] => NAME
[operator] => startswith
[value] => as
[ignoreCase] => 1
)
[1] => Array
(
[isComplex] =>
[field] => MAIN_PHONE
[operator] => startswith
[value] => 06
[ignoreCase] => 1
)
[2] => Array
(
[isComplex] =>
[field] => COD_FISC
[operator] => startswith
[value] => 98
[ignoreCase] => 1
)
[3] => Array
(
[isComplex] =>
[field] => id
[operator] => startswith
[value] => 12
[ignoreCase] => 1
)
希望这段代码很清楚。有什么建议?尝试了几种方式,但仍未找到解决方案。
答案 0 :(得分:0)
尝试使用递归:
$global_var;
function recursive($node)
{
// grab informations into $global_var
if(has_no_subnodes) return;
else recursive($node->subField);
}