这是我的代码。我不知道为什么它不工作。我试图用php for loop打印我的表格,但是网站上什么也没有显示。Nothing
这是我试图打印出来的二维数组。
<!--Arrays of weapons-->
<?php
$weapons = array(
array("M4A1",1,78906,"TUCKER, LISBETH","SPC"),
array("M4A1",2,78915,"HATHAWAY, HANNAH","1LT"),
array("M4A1",3,78933,"HARRIS, LEE","SFC"),
array("M4A1",4,78934,"WELCH, BRAD","SSG"),
array("M9",1,1167552,"BLAND, MARGARET","CPT"),
array("M249",1,101032,"TYSON, MICHELLE","1SG"),
array("M249",2,101038,"MEDINA, TOBIAS","SPC"),
array("M240B",1,104104,"COSTA, JOSHUA","SSG"),
array("M2A1",1,1863848,"GARCIA, RIGOBERTO","SSG"),
array("MK-19",1,19369,"NEUPANE, KISHOR","SPC")
);
?>
这是我试图用来打印输出的代码。
<!--Create the Weapons List Table-->
<table border ="1">
<tr>
<th>Type</th>
<th>Buttstock #</th>
<th>Serial #</th>
<th>Name</th>
<th>Rank</th>
</tr>
<!--Put two-dimentinal arrays in the table-->
<?php foreach ($row = 0; $row < 10, $row++) {?>
<tr>
<?php for ($col = 0; $col < 5, $col++) {?>
<td><?php echo $weapons[$row][$col];?></td>
<?php }?>
</tr>
<?php }?>
</table>
https://stackoverflow.com/questions/49584733
复制相似问题