Source Code:
(back to article)
<?php function print_array($arr, $indent = 0) { foreach ($arr as $item) { if (is_array($item)) { print_array($item, $indent + 1); } else { echo str_repeat(" ", $indent) . $item . "\n"; } } } $my_array = [1, 2, [3, 4, [5, 6], 7], 8]; print_array($my_array);
Result:
Report an issue