首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >PHP多维数组

PHP多维数组
EN

Stack Overflow用户
提问于 2018-03-31 13:57:40
回答 1查看 88关注 0票数 1

这是我的代码。我不知道为什么它不工作。我试图用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>
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49584733

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档