//Array depth traversal
function testFunc($array){
foreach ($array as $value){
if (is_array( $value )) {
testFunc($value);
} else {
echo
$value."
";
}
}
}
//Start test data
$testarr = array(
1,
array(
6,
array(
16,
17,
18
),
8,
9,
array(
19,
array(
25,
26,
27
)
)
),
3,
4,
array(
11,
array (
21,
22,
23
),
13,
14,
array(
24,
array(
28,
29,
30
)
)
)
);
testFunc($testarr);
?>
The above introduces PHP array depth traversal, including PHP content. I hope it will be helpful to friends who are interested in PHP tutorials.