我需要导航这个数组
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
)
)
)
)
我想要得到的结果是只有带有密钥字段的数组
Es:结果:
[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
)
希望这个代码是明确的。有什么建议吗?尝试了几种模式,但仍未找到解决方案。
尝试递归:
$global_var;
function recursive($node)
{
// grab informations into $global_var
if(has_no_subnodes) return;
else recursive($node->subField);
}