Created
March 5, 2018 10:19
-
-
Save MohammedAttya2/fe82e6f2d73f7e8f0074ea8e3ca2692a to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Collapse an array of arrays into a single array. | |
* | |
* @param array $array | |
* @return array | |
*/ | |
public static function collapse($array) | |
{ | |
$results = []; | |
foreach ($array as $values) { | |
if ($values instanceof Collection) { | |
$values = $values->all(); | |
} elseif (! is_array($values)) { | |
continue; | |
} | |
$results = array_merge($results, $values); | |
} | |
return $results; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment