如何将循环放入html表?

aro*_*n n 0 html php loops for-loop

foreach($匹配为$ match){echo match [1]." - ".match [2];}

我想要match[1]match[2]值应该显示在一个包含两列的html表中.例如

Name    |   Percent
--------|-----------
Mathew  |   95%
Run Code Online (Sandbox Code Playgroud)

mathew是哪里match[1],百分比是match[2]

我如何在两者之间添加html标签,对于你的信息,大约有50个名字.

小智 5

<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>
Run Code Online (Sandbox Code Playgroud)

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