First type
Want 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 results are:
0=>linux Server Configuration and management
1=>array
Of course, I actually want all the specifics, not the output array ...
So 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 $book each $value (AS)
if (Is_array ($val)) foreach ($val as $value) echo $va Lue. ';
The output is:
0=>linux Server Configuration and management
Lk
Ok
Above this PHP use foreach () traversal two-dimensional array of simple example is small series to share all the content, hope to give you a reference, also hope that we support cloud habitat community.