PHPverse 2025

Voting

: max(four, three)?
(Example: nine)

The Note You're Voting On

Edgar
3 years ago
<?php
$array
= [
'A','B',
'C'=>[
'D','E',
'F'=>['G','H']
],
'I','J'
];

$iterator = new RecursiveArrayIterator($array);

foreach(
$iterator as $key=>$value)
{
echo
$key,':', $value,'<br>';
}

/**
Output
0:A
1:B
C:Array
2:I
3:J
*/

//-------------
//Recursive...

$array = [
'A','B',
'C'=>[
'D','E',
'F'=>['G','H']
],
'I','J'
];

$it = new RecursiveArrayIterator($array);
$iterator = new RecursiveIteratorIterator($it);

foreach(
$iterator as $key=>$value)
{
echo
$key,':', $value,'<br>';
}

/**
Output
0:A
1:B
0:D
1:E
0:G
1:H
2:I
3:J
*/

?>

<< Back to user notes page

To Top