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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 08:54:14
Original
1014 people have browsed it

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

Related labels:
php
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template