foreach遍历 < 创建表 >练习题

原表如下:

效果图如下:

<table border="1" width="500" height="260">
<tr>
    <th>code</th>
    <th>name</th>
    <th>sex</th>
    <th>nation</th>
    <th>birthday</th>
</tr>
<?php
$attr=array(
    array("p001","胡军",0,"n003","1985-08-09 00:00"),
    array("p002","周丹",1,"n001","1984-04-17 00:00"),
    array("p003","吴倩",1,"n004","1981-10-29 00:00"),
    array("p004","唐默",0,"n001","1983-02-25 00:00")
);
    foreach ($attr as $v)
    {
        echo "<tr>
            <td>{$v[0]}</td>
            <td>{$v[1]}</td>

            <td>{$v[2]}</td>
            <td>{$v[3]}</td>
            <td>{$v[4]}</td>
            </tr>";    
    }
?>
</table>
原文地址:https://www.cnblogs.com/zxl89/p/6028315.html