我如何把循环放入HTML表格? [英] how do I put loop into html table?

查看:875
本文介绍了我如何把循环放入HTML表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

foreach($ match as $ match){echo match [1]。 - 。match [2];}

我想 match [1] match [2] 值应该显示在一个有两列的html表格中。例如

  Name |百分比
-------- | -----------
Mathew | 95%

其中mathew是 match [1] 和百分比是 match [2]



如何在两者之间添加html标签, 50个名字。

解决方案

 < table> 
< tr>
< th>名称< / th>
第百分比/第二百分比
< / tr>
<?php foreach($ matches as $ match):?>
< tr>
< td><?php print $ match [1]; ?>< / TD>
< td><?php print $ match [2]; ?>< / TD>
< / tr>
<?php endforeach; ?>
< / table>

小心你的意思是匹配[1]和匹配[2]而不匹配[0]并匹配[1] ... PHP数组中的第一个元素是0。


foreach($matches as $match){ echo match[1]."-".match[2];}

I want match[1] and match[2] value should be displayed in an html table with two columns. for example

Name    |   Percent
--------|-----------
Mathew  |   95%

where mathew is match[1] and percent is match[2]

How I add html tags in between and for your info there were about 50 names.

解决方案

<table>
<tr>
  <th>Name</th>
  <th>Percent</th>
</tr>
<?php foreach($matches as $match): ?>
  <tr>
    <td><?php print $match[1]; ?></td>
    <td><?php print $match[2]; ?></td>
  </tr>
<?php endforeach; ?>
</table>

Be careful that you really mean match[1] and match[2] and not match[0] and match[1]... the first element in a PHP array is 0.

这篇关于我如何把循环放入HTML表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆