从php读取复杂数组

时间:2015-12-21 05:01:56

标签: php arrays

我从webservice获得了这个数组,所以如何在foreach循环中读取它?或者一些简单的方法来阅读它。 [组]他们超过12 [id] 有。。

Array 
( [response] => Array ( 
    [single] => Array ( [parameters] => Array ( [0] => Array ( [name] => msgCode [value] => 0101 ) 
                                                [1] => Array ( [name] => msgDesc [value] => OK ) 
                                                [2] => Array ( [name] => status [value] => 1) 
                                                [3] => Array ( [name] => message [value] => Normal) ) ) 
    [group] => Array ( [id] => N4BD767 [parameters] => Array ( [0] => Array ( [name] => idFee [value] => 000 ) echo
                                                                [1] => Array ( [name] => typeFee [value] => Cuota) 
                                                                [2] => Array ( [name] => entryDate [value] => 2014-12-17T14:06:47-03:00 ) 
                                                                [3] => Array ( [name] => expirationDate [value] => 2015-12-05T00:00:00-03:00) 
                                                                [4] => Array ( [name] => amountOrigin [value] => 221980) 
                                                                [5] => Array ( [name] => surcharges [value] => 1856) 
                                                                [6] => Array ( [name] => entity [value] => ONLINE) 
                                                                [7] => Array ( [name] => feeStatus [value] => inicial ) 
                                                                [8] => Array ( [name] => tranNumber [value] => 27) ) ) ) )   

1 个答案:

答案 0 :(得分:0)

好的伙计们,这就是我所做的,它运作良好。没有foreach。

$output = array();  
array_walk_recursive($result, function($item,$key) use (&$output){ 
    array_push($output,$key,$item);
});  
echo var_dump($output);