前端之家收集整理的这篇文章主要介绍了
PHP中遍历二维数组_以不同形式的输出操作实例,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如下所示:
<?PHP
//定义二维索引数组
$arr = array(
array("101","李军","男","1976-02-20","95033"),array("103","陆君","1974-06-03","95031"),array("105","匡明","1975-10-02",array("107","王丽","女","1976-01-23",array("108","曾华","1977-08-01",array("109","王芳","1975-02-10","95031")
);
第一种输出形式(echo语句)
/* echo "
";
echo "<tr><td>Sno</td><td>Sname</td><td>Ssex</td><td>Sbirthday</td><td>Class</td></tr>";
foreach($arr 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>";
}
echo "</table>" ;