3v4l.org

run code in 300+ PHP versions simultaneously
<?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);

preferences:
33.53 ms | 402 KiB | 5 Q