<?php
$array = array(array("aaa1", "aaa2", "aaa3", "aaa4"),
array("bbb1", "bbb2", "bbb3", "bbb4"),
array("ccc1", "ccc2", "ccc3", "ccc4"),
array("ddd1", "ddd2", "ddd3", "ddd4"));
?>
<table border="2">
<?php
foreach($array as $arr): ?>
<tr>
<?php foreach($arr as $a):
echo "<td>" . $a . "</td>";
endforeach; ?>
</tr>
<?php endforeach;
?>
</table>
这告诉我:
aaa1 aaa2 aaa3 aaa4
bbb1 bbb2 bbb3 bbb4
ccc1 ccc2 ccc3 ccc4
ddd1 ddd2 ddd3 ddd4
我想收到:
aaa1 bbb1 ccc1 ddd1
aaa2 bbb2 ccc2 ddd2
aaa3 bbb3 ccc3 ddd3
aaa4 bbb4 ccc4 ddd4
但我必须使用 FOREACH,而不是 FOR。如果这更容易,我可以使用 DIV,但是如何使用?
我怎样才能做到?