我已经对数组进行了排序,这些数组在var_dump时看起来是这样的。
array (size=11)
'The Matrix' => float 9.5
'Fight Club' => float 9.5
'Inception' => float 8.5
'The Usual Suspects' => float 7.5
'Shutter Island' => float 7.5
'The Prestige' => float 7
'The Dark Knight' => float 7
'The Departed' => float 6
'Matchstick Men' => float 5.5
'The Green Mile' => float 5
'Forrest Gump' => float 4.5数组使用数据库中电影的标题和分级,因此当在数据库中添加/更改电影或分级时,数组中的数据将发生变化。我的问题是:
如何从这个数组中生成HTML表?
发布于 2015-12-06 15:56:29
就这样吧:
echo '<table>';
echo '<tr>
<th>Movie</th>
<th>Title</th>
</tr>';
foreach ($arr as $key=>$val) {
echo '<tr>
<td>'.$key.'</td>
<td>'.$val.'</td>
</tr>';
}
echo '</table>';https://stackoverflow.com/questions/34119378
复制相似问题