Source Code:
(back to article)
<?php function array_flatten($array) { $result = []; foreach ($array as $element) { if (is_array($element)) { $result = array_merge($result, array_flatten($element)); } else { $result[] = $element; } } return $result; } $multi_dimensional_array = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']]; print_r(array_flatten($multi_dimensional_array));
Result:
Report an issue