CSVファイルを読み取るスクリプトがあります。
<?php
echo '<table border="0" cellspacing="1" cellpadding="1" class="sortable" border="1"><caption>Title Here</caption>
<thead><tr><th class="header">Time:</th><th class="header">Value 1:</th><th class="header">Value 2:</th><th class="header">Value 3:</td class="header"><th class="header">Value 4:</th><th class="header">Value 5:</th><th class="header">Value 6:</th><th class="header">Value 7:</th><th class="header">Value 8:</th><th class="header">Value 9:</th></tr></thead><tbody><tr>';
$row = 1;
if (($handle = fopen("data.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
$row++;
for ($c=0; $c < $num; $c++) {
if ($c==9) { echo "<td>".$data[$c] ."</td></tr><tr>";}
else {echo "<td>".$data[$c] ."</td>"; }
}
}
fclose($handle);
}
echo '</tbody></table>';
?>
このスクリプトは、データを取得してhtmlテーブルに出力するだけです。テーブルを並べ替えたいだけです。たとえば、csvにはこれらのコンテンツが含まれている場合があります
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7
私はアウトがなることを望みます:
0 0 0 0
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
続けてください...私はいくつかの追加のループを配置する必要があります..どうすればそれを行うことができますか?