Last active
October 12, 2015 18:31
-
-
Save sarfraznawaz2005/73a1cac706b943c2e0c5 to your computer and use it in GitHub Desktop.
flatten multi-dimensional 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 | |
/** | |
* | |
* @flatten multi-dimensional array | |
* | |
* @param array $array | |
* | |
* @return array | |
* | |
*/ | |
function flattenArray(array $array){ | |
$ret_array = array(); | |
foreach(new RecursiveIteratorIterator(new RecursiveArrayIterator($array)) as $value) | |
{ | |
$ret_array[] = $value; | |
} | |
return $ret_array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment