The first type of
To traverse the entire two-dimensional array with foreach ():
$team = Array (' lk ', ' OK '), $book = Array (' Linux server Configuration and Management ', $team); foreach ($book as $k + $val)//for $book each $value (AS) echo $k. ' = '. $val. ';
The output is:
0=>linux Server Configuration and management
1=>array
Of course, I actually want all the details, not the output array ...
Therefore, you should use the following procedure to add a judgment statement:
$team = Array (' lk ', ' OK '), $book = Array (' Linux server Configuration and Management ', $team); foreach ($book as $k + $val)//means for $book each $value (AS) if (Is_array ($val)) foreach ($val as $value) echo $value. ' ' Else echo $k. ' = '. $val. ';
The output is:
0=>linux Server Configuration and management
Lk
Ok
echo "<br>", echo "
The second type of
foreach () iterates over a multidimensional array:
<?php//declares a three-dimensional array $info =array ("User" =>array (Array (1, "Zhangsan", "Nan" "), Array (2," Lisi "," Nan "), Array (3," Wangwu ", +," 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 traversal, output a table foreach ($info as $tableName + = $table) {echo "<table align= ' center ' border= ' 1 ' width=300>"; echo "& Lt;caption>