-3
$locations = array(
    array('Eifel Tower', 48.858278, 2.294254, '#FF7B6F', 'eifel-tower.jpg', 120, 160),
    array('The Louvre', 48.8640411, 2.3360444, '#6BE337', 'the-louvre.jpg', 160, 111), 
    array('Musee d\'Orsay', 48.860181, 2.3249648, '#E6E325', 'musee-dorsay.jpg', 160, 120), 
    array('Jardin du Luxembourg', 48.8469529, 2.337285, '#61A1FF', 'jardin-du-luxembourg.jpg', 160, 106), 
    array('Promenade Plantee', 48.856614, 2.3522219, '#FF61E3', 'promenade-plantee.jpg', 160, 120)
);

我可以在循环中重复内部数组吗,因为我需要它从数据库中重复。谢谢!

4

2 回答 2

2

正如Houssni发布的那样,但你也可以这样做:

foreach ($location as $location_array)
{
    foreach ($location_array as $location_detail)
    {
        var_dump($location_detail);
    }
}
于 2013-10-31T08:05:22.897 回答
1

嵌套for循环就是答案:

for ($i = 0; $i < count($locations); $i++)
{
    for ($j = 0; $j < count($locations[$i]); $j++)
    {
        echo $locations[$i][$j];
    }
}
于 2013-10-31T08:03:56.933 回答