Php: php array breadth traversal :;}} if (! Empty ($ arr) {while ($ tempcurrent ($ arr) // Array breadth traversal
Function testFunc ($ array ){
$ Arr = array ();
Foreach ($ array as $ value ){
If (is_array ($ value )){
$ Arr [] = $ value;
} Else {
Echo $ value ."
";
}
}
If (! Empty ($ arr )){
While ($ temp = current ($ arr )){
Foreach ($ temp as $ val ){
If (is_array ($ val )){
$ Arr [] = $ val;
} Else {
Echo $ val ."
";
}
}
Unset ($ arr [key ($ arr)]);
}
}
}
// Start the 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 the php array breadth traversal, including the php content, hope to be helpful to friends who are interested in the PHP Tutorial.