要制作一个表格,你可以使用HTML和PHP来完成。下面是一个简单的例子:
<?php
// 假设你有一个包含数据的数组
$data = array(
array('John', 'Doe', 'john@example.com'),
array('Jane', 'Smith', 'jane@example.com'),
array('Bob', 'Johnson', 'bob@example.com')
);
?>
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
</tr>
<?php foreach ($data as $row): ?>
<tr>
<?php foreach ($row as $cell): ?>
<td><?php echo $cell; ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>
在这个例子中,我们首先定义了一个包含数据的数组 $data。然后,我们使用HTML的 <table> 标签来创建一个表格。在表格的第一行,我们使用 <th> 标签定义了表头。接下来,我们使用嵌套的 foreach 循环来遍历数据数组,并在每个单元格中输出数据。最后,我们将整个表格的HTML代码包含在一个PHP的 echo 语句中,以便将其输出到浏览器。
上一篇:php分页浏览器
下一篇:php单次循环耗时
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站