如何在第一行中显示第一个数组,然后在第二行中显示第二个数组,然后在第三行中显示第三个数组
Array
(
[S] => Array
(
[0] => Array
(
[id] => 61
[area_code] => SS-5
)
)
[A] => Array
(
[0] => Array
(
[id] => 24
[area_code] => AHUP-9
)
)
)
答案 0 :(得分:0)
结合使用简单的foreach
循环:
foreach($data as $upkey=>$set){
foreach($set as $ind=>$value){
echo $value['area_code'];
if (isset($set[$ind+1])) echo '-----';
}
echo PHP_EOL;
}
如果您需要一个包含列和行的表,则可以使用简单的示例,例如:
// open table(thead included) and tbody tags
echo '<table class="table"><thead></thead><tbody>';
foreach($data as $set){
// open row
echo '<tr>';
foreach($set as $value){
// print column with value
echo '<td>'.$value['area_code'].'</td>';
}
// close row
echo '</tr>';
}
// close tbody and table tags
echo '</tbody></table>';