Skip to content

Instantly share code, notes, and snippets.

@kapolos
Created September 4, 2015 06:38
Show Gist options
  • Save kapolos/28cd029013cb533f2425 to your computer and use it in GitHub Desktop.
Save kapolos/28cd029013cb533f2425 to your computer and use it in GitHub Desktop.
/**
* Recursively flattens an array
*
* @param array $arr
*
* @return array
*/
function flatten(array $arr)
{
$recursiveIterator = new RecursiveArrayIterator($arr);
$recursiveIteratorIterator = new RecursiveIteratorIterator($recursiveIterator);
return iterator_to_array($recursiveIteratorIterator, FALSE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment