Home >Backend Development >PHP Tutorial >Foreach traversal example of multi-dimensional array in PHP_PHP tutorial

Foreach traversal example of multi-dimensional array in PHP_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:28:13794browse

Copy code The code is as follows:

//Declare a three-dimensional array
$info=array(
"user"=>array(
array(1,"zhangsan",20,"nan"),
array(2,"lisi",20,"nan"),
array(3,"wangwu",25,"nv")
),
"score"=>array(
array(1,100,98,95,96),
array(2 ,56,98,87,84),
array(3,68,75,84,79)
),
"connect"=>array(
array(1,'2468246 ',"salkh@bbs.com"),
array(2,'343681643',"aikdki@sina.com"),
array(3,'3618468',"42816@qq.com")
)
);
//Loop through and output a table
foreach($info as $tableName=>$table){
echo "";
echo "";//With the key of each array Value as table name
foreach($table as $row){
echo "";
foreach($row as $col){
echo "";
}
echo "";
}
echo "

".$tableName."

". $col."
";
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/802223.htmlTechArticleCopy the code as follows: ?php //Declare a three-dimensional array $info=array( "user"=array( array(1,"zhangsan",20,"nan"), array(2,"lisi",20,"nan"), array(3,"wangwu",25,"nv") ), "score"= a...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn