PHP遍历数组,分别将内容加⼊到table表格中
<?php
header("content-type:text/html;charset=utf-8");//编码
$com_list=array();
$com_list[0]=array("id"=>1,"name"=>"联⽹Y450笔记本","money"=>4300,"save"=>56,"data"=>"2018-3-11");
$com_list[1]=array("id"=>2,"name"=>"联⽹G430笔记本","money"=>3300,"save"=>3,"data"=>"2018-3-12");
$com_list[2]=array("id"=>3,"name"=>"联⽹G420笔记本","money"=>2300,"save"=>8,"data"=>"2018-3-13");
$com_list[3]=array("id"=>4,"name"=>"⼩⽶9","money"=>3200,"save"=>32,"data"=>"2018-3-12");
$com_list[4]=array("id"=>5,"name"=>"华为P20","money"=>1500,"save"=>26,"data"=>"2018-3-8");
>
<table border="1">
<thead>
<tr>
<td>id</td>
<td>title</td>
<td>stork</td>
<td>addtime</td>
<td>data</td>
</tr>
</thead>
<tbody>
<?php foreach($com_list as$vlue){?>//循环遍历
<tr>
//显⽰对应内容
<td><?php echo$vlue["id"]?></td>
php中header是什么意思<td><?php echo$vlue["name"]?></td>
<td><?php echo$vlue["money"]?></td>
<td><?php echo$vlue["save"]?></td>
<td><?php echo$vlue["data"]?></td>
</tr>
<?php}?>
</tbody>
</table>
实现效果

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。