tr
を含む出力 td をループする方法例:$arr1=array("a","b","c","d","e","f","g");その上。
次の効果を得る
foreach(array_chunk($arr1,4) as $v){ echo "<tr>n"; foreach($v as $t) echo "<td>".$t."</td>n"; echo "</tr>n"; }; <br><font color="#e78608">------解決策---------</font><br>$arr1=array("a"," b ","c","d","e","f","g"); <br><br>$i = 1;<br>echo '</tr><tr>';<br>foreach ( $arr1 as $key=>$val)<br>{<br> echo '<td>' , $val, '</td>';<br> if($i%4 == 0 ) echo "</tr><tr>";<br> ++$i;<br>}<br>echo '</tr>';<br><br> <div class="clear"></div> </tr>