PHP中多维数组的foreach遍历示例

前端之家收集整理的这篇文章主要介绍了PHP中多维数组的foreach遍历示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<div class="codetitle"><a style="CURSOR: pointer" data="34948" class="copybut" id="copybut34948" onclick="doCopy('code34948')"> 代码如下:

<div class="codebody" id="code34948">
<?PHP
//声明一个三维数组
$info=array(
"user"=>array(
array(1,"zhangsan",20,"nan"),
array(2,"lisi",
array(3,"wangwu",25,"nv")
),
"score"=>array(
array(1,100,98,95,96),56,87,84),68,75,84,79)
),
"connect"=>array(
array(1,'2468246',"salkh@bbs.com"),'343681643',"aikdki@sina.com"),'3618468',"42816@qq.com")
)
);
//循环遍历,输出一个表格
foreach($info as $tableName=>$table){
echo "";
echo "";//以每个数组的键值作为表名
foreach($table as $row){
echo "<tr>";
foreach($row as $col){
echo "<td>".$col."</td>";
}
echo "</tr>";
}
echo "</table>";
}
?>

原文链接:https://www.f2er.com/php/24488.html

猜你在找的PHP相关文章

".$tableName."