Array( [1JANATAMF] = Array ( [0] = 4.10 [1] = 5.10 [2] = 6.10 [3] = 7.10 [4] = 8.10 [5] = 5 [6] = 0.02 [7] = 5413 ) [1STPRIMFMF] = Array ( [0] = 12.90 [1] = 1.90 [2] = 16.90 [3] = 11.90 [4] = 14.90 [5] = 24 [6] = 04 [7] = 10 )我有这样的数组。现在我想在表中打印,其中包含表行上主数组的键名称(一次)及其所有值。我想要的表是这样的:1JANATAMF 4.10 5.10 6.10 7.10 8.10 5 0.02 54131STPRIMFMF 12.90 1.90 16.90 11.90 14.90 24 04 10我的代码是这样的,它将所有键打印在一起并在最后打印一些值。foreach ($c as $keys =>$values) echo $keys . " ";`enter code here` foreach ($values as $key=>$data) echo " " . $data . "<br>";
2 回答
肥皂起泡泡
TA贡献1829条经验 获得超6个赞
你必须使用简单的foreach():
foreach($array as $key=>$value){?>
<tr>
<td><?php echo $key;?></td>
<?php foreach($value as $val){?>
<td><?php echo $val;?></td>
<?php } ?>
</tr>
<?php }?>
饮歌长啸
TA贡献1951条经验 获得超3个赞
一种方法是您可以像这样使用 array_values() 和 foreach() :
$arrVals = array_values($1JANATAMF)
foreach($arrVals as $value){
// Use Html To Create Table and add $value to columns
}
- 2 回答
- 0 关注
- 113 浏览
添加回答
举报
0/150
提交
取消