2011-01-21 89 views

回答

2

是的,這是100%好&如果你需要它有效。

PS。嘗試之前詢問;-)

3

我不太清楚你'是否公平'的意思,但你肯定可以嵌套foreach循環。下面的代碼給出了一個如何實現的例子;

$locations = array(
    'my_house' => array('hallway', 'living_room', 'dining_room', 'kitchen', 'bedroom', 'toilet'), 
    'my_office' => array('entrance', 'work_room', 'toilet') 
); 

foreach($locations as $building => $rooms) { 
    echo "Listing rooms in $building... <br />"; 

    foreach($rooms as $room) { 
    echo $room . "<br />"; 
    } 

    echo "<br /><br />"; 
} 
相關問題