Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP: array_flatten - método para deixar array multidimensional com 1 dimensão apenas.
/**
* Função para deixar uma array multidimensional em 1 índice apenas.
* @see http://stackoverflow.com/a/1320259/390946
* @author Julio Vedovatto <juliovedovatto@gmail.com>
* @param array $array
* @return array
*/
function array_flatten(array $array) {
$return = array();
array_walk_recursive($array, function($a) use (&$return) { $return[] = $a; });
return $return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.