如何利用php语法转换为表格输出

2025年01月17日 建站教程

<?php
$students = array(
  array("name"=>"张三", "age"=>18, "score"=>80),
  array("name"=>"李四", "age"=>20, "score"=>90),
  array("name"=>"王五", "age"=>22, "score"=>95)
);
?>
<table>
  <tr>
    <th>姓名</th>
    <th>年龄</th>
    <th>分数</th>
  </tr>
  <?php foreach($students as $student): ?>
    <tr>
      <td><?php echo $student['name']; ?></td>
      <td><?php echo $student['age']; ?></td>
      <td><?php echo $student['score']; ?></td>
    </tr>
  <?php endforeach; ?>
</table>

本文链接:http://so.lmcjl.com/news/21511/

展开阅读全文
相关内容