-
-
Save rowild/541e3320c44cb19f482b to your computer and use it in GitHub Desktop.
Function to recursively flatten multidimensional PHP array.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Requires PHP 5.3+ | |
// Found here: http://stackoverflow.com/a/1320156 | |
function flatten_array(array $array) { | |
$flattened_array = array(); | |
array_walk_recursive($array, function($a) use (&$flattened_array) { $flattened_array[] = $a; }); | |
return $flattened_array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment