我需要将标题放在下面这个代码创建的表的顶部:表有9列,是用Shell脚本文本文件创建的,要怎么做?
$myfile = file_get_contents('/ftpfiles/monitor-data') or die ("Unable");
$table = '<table border="2" width="100%" height="500" style="border-collapse: collapse; border: 3px solid #0000FF" bordercolorlight="#0000FF">';
$trimmed = trim($myfile);
$filearray = explode("
", $trimmed);
foreach($filearray as $row) {
// here separate your row that is a string, into an array
$cols = explode(" ", $row);
$table .= '<tr>';
foreach($cols as $value) {
$table .= '<td align = "center">'.$value.'</td>';
}
$table .= '</tr>';
}
$table .= '</table>';
echo $table;