$specs = array ('Name' => 'Cleopatra', 'Year' => '2008', 'Length' => '20ft', 'Make' => 'manufacturer', 'Model' => 'model', 'Engines Count' => '2', 'Fuel' => 'Diesel', 'Rudder' => 'rudder', 'Keel' => 'keel', 'Price' => '$1');
foreach ($specs as $label => $detail) {
echo "<tr>";
echo "<th>{$label}</th>";
echo "<td>{$detail}</td>";
echo "</tr>";
}
foreach循環在每行中返回1列。我怎樣才能使每行4列,像這樣計數數組項並在特定數字後添加div
<tr>
<th>Label</th>
<td>Detail</td>
<th>Label</th>
<td>Detail</td>
<th>Label</th>
<td>Detail</td>
<th>Label</th>
<td>Detail</td>
</tr>
<tr>
<th>Label</th>
<td>Detail</td>
<th>Label</th>
<td>Detail</td>
<th>Label</th>
<td>Detail</td>
<th>Label</th>
<td>Detail</td>
</tr>
每列4行?或每列的列?你的例子是每行的列。 – Jon 2011-12-14 20:15:22
編輯。感謝您的注意 – CyberJunkie 2011-12-14 20:17:22