php中如何把数组输出到表格 我会横向的 纵向的不知如何循环 10
$num=array(10,30,50,70,90,);
$add=0;
foreach($num as $d){
echo $d." ";
$add+=$d;
}
echo $add."<br>";
?>
<?php
$dqlist=array(
array("name"=>"洗衣机","brand"=>"海尔","price"=>"1000"),
array("name"=>"电视机","brand"=>"长虹","price"=>"2000"),
array("name"=>"冰箱","brand"=>"LG","price"=>"3400"),
);
foreach($dqlist as $x)
foreach($x as $y => $z){
echo $x["name"] ;
}
?>
<table border="1">
<tr><th>name</th><td></td></tr>
<tr><th>brand</th><td></td></tr>
<tr><th>price</th><td></td></tr>
</table>
我现在要把array中的 第一个的三个值分别写在表格中的三个格子中
然后再输出一个表格写第二个的三个值
还有th里面的三个键能不能也用php输出 展开
2014-03-10
<table border="1">
<tr>
<th>name</th>
<th>brand</th>
<th>price</th>
</tr>
<?php
header("Content-type:text/html;charset=utf8");
$dqlist=array(
array("name"=>"洗衣机","brand"=>"海尔","price"=>"1000"),
array("name"=>"电视机","brand"=>"长虹","price"=>"2000"),
array("name"=>"冰箱","brand"=>"LG","price"=>"3400"),
);
foreach($dqlist as $k=>$x)
{
echo "<tr>";
echo "<td>".$x['name']."</td>";
echo "<td>".$x['brand']."</td>";
echo "<td>".$x['price']."</td>";
echo "</tr>";
}
?>
</table>
效果是这样的
2014-03-10