こんにちは、私はアルファベット順に映画名の配列を持っています.htmlテーブルを作成したいのですが、その場でこれを行いたいので、次のことを行いました:
echo "<div align=\"center\"><table>";
$i=0;
foreach ($results as $entry){
//If first in row of 4, open row
if($i == 0) {
echo "<tr>\n";
}
//print a cell
echo "\t<td>" . $entry . "</td>\n";
i++;
//if last cell in row of 4, close row
if($i == 4) {
echo "</tr>\n";
$i=0;
}
}
if($i < 4) {
while($i < 4) {
echo "\t<td></td>\n";
$i++;
}
echo "</tr>\n";
}
echo "</table></div>";
ただし、これは次のようなテーブルを作成します。
entry0 | entry1 | entry2 | entry3
entry4 | entry5 | entry6 | entry7
次のようなテーブルを作成するにはどうすればよいですか。
entry0 | entry3 | entry6
entry1 | entry4 | entry7
entry2 | entry5 | entry8
?
$results 配列を再編成し、同じ方法でテーブルを作成する必要があると思いますか?
私はphpに非常に慣れていないので(1週間!)、どうすればいいのかよくわかりません
ご協力いただきありがとうございます