如何循环以下的php数组?

时间:2016-12-01 09:59:21

标签: php multidimensional-array

我想循环遍历以下数组。

array(2)  {
    [0]=> array(6) {
        [0]=> string(10) "excel_id "
        [1]=> string(12) "excel_name "
        [2]=> string(11) "excel_email"
        [3]=> string(13) "excel_address"
        [4]=> string(12) "excel_giveby"
        [5]=> string(16) "excel_accesories" 
    } 
    [1]=> array(6) {
        [0]=> float(111)
        [1]=> string(10) "sh1exname1"
        [2]=> string(11) "sh1exemail1"
        [3]=> string(12) "sh1exaddress"
        [4]=> string(12) "sh1exgivenby"
        [5]=> string(16) "sh1exaccesorries" 
    }    
}

任何人都可以帮助我吗?

2 个答案:

答案 0 :(得分:2)

如果你尝试了任何东西,你应该找到foreach。 这将遍历所有数组值。 您可以使用如下的多维foreach简单地遍历多维数组:

foreach($array as $parentValue)
{
    foreach($parentValue as $childValue)
    {
        // your code
    }
}

答案 1 :(得分:0)

试试这个:

foreach ($main_array as $outer_entry){

    foreach($outer_entry as $entity){
        print_r($entity);
    }

}
相关问题