That's a perfect job for Iterators:
$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
foreach($iterator as $key => $value) {
echo "$key => $value\n";
}
See Introduction to SPL Iterators and Live Demo on codepad
EDIT: the alternative would be array_walk_recursive as show in Finbarr's answer belowarray_walk_recursive as show in Finbarr's answer below