Home >Backend Development >PHP Tutorial >PHP array depth traversal PHP7 PHP environment construction PHP from entry to proficiency

PHP array depth traversal PHP7 PHP environment construction PHP from entry to proficiency

WBOY
WBOYOriginal
2016-07-29 08:54:14977browse

//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.

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