- print_r: documentation ( source)
- array_walk_recursive: documentation ( source)
<?php
$arr = array(
'one' => 'hi there',
'two' => 'hello there',
'three' => array(
'one' => 'hey d00d',
'two' => 'greetings',
),
);
$gather = array();
function step_and_gather($item, $key, &$gather) {
$gather[] = $item;
echo "==> Gathering at {$key}\n";
print_r($gather);
}
array_walk_recursive($arr, 'step_and_gather', $gather);
echo "==> Final answer <==\n";
print_r($arr);