我有一個動態數組:如何以示例的方式將數組更改爲html表格?
Array
(
[user1] => Array
(
[012014] => 6788
[022014] => 11141
[032014] => 6143
[042014] => 936
[052014] => 936
)
[user2] => Array
(
[012014] => 9
[022014] => 25
[032014] => 37
[042014] => 17
[052014] => 16
)
)
我想是這樣顯示的:我好像
Users | Months
|---------------------------------
|012014|022014|032014|042014|052014
------------------------------------------
user1 | 6788 | 11141| 6143 | 936 | 936
-------------------------------------------
user2 | 9 | 25 | 37 | 17 | 16
不能做得出來!這是我一直在嘗試:
echo "<table>";
foreach($month_all as $site=>$value){
echo "<tr>";
echo "<td>$site</td>";
foreach ($value as $column) {
echo "<td>$column</td>";
}
echo "</tr>";
}
echo "</table>";
任何方式,我可以做到這一點乾淨的方式?
您需要2'foreach'循環。 –