获得KEY& PHP中数组的值

时间:2015-09-30 06:45:06

标签: php

我的数组看起来像bleow

Array ( 
    [number] => 
         Array ( 
            [0] => Array ( 
               [0] => stdClass Object ( [phone_number] => 123456891 ) ) 
               [1] => Array ( 
                   [0] => stdClass Object ( [phone_number] => 2356894156 )      ) ) )

我怎样才能使用for循环来检索phone_numbers 提前谢谢

1 个答案:

答案 0 :(得分:1)

<?php
        $arr = [ 
                'number' => array ( 
                    '0' => array(
                        '0' => (object) array('phone_number'=>123456891)
                    ),

                    '1' => array(
                        '0' => (object) array('phone_number'=>2356894156)
                    )
                ) 
        ];

       foreach($arr as $val){
         foreach($val as $val1){
           foreach($val1 as $val2){
              echo $val2->phone_number."<br>";
           }
         }  
      }

?>