Arr.php
public static function collapse(array $array) : array
    {
        $results = [];

        foreach ($array as $key => $item) {

            // Nested arrays will be merged in (non-recursively).
            if (is_array($item)) {
                $results = array_merge($results, $item); continue;
            }

            // Values with numeric keys will be appended in any case.
            if (is_int($key)) {
                $results[] = $item; continue;
            }

            // Non-numeric keys. If we've got the given key in $results already, it means it was merged
            // in from one of the nested arrays and those are meant to overwrite the initial values on collisions -
            // thus we're not going to do anything in that case.
            if (!array_key_exists($key, $results)) {
                $results[$key] = $item;
            }
        }

        return $results;
    }
public static function collapse(array $array) : array
    {
        $results = [];

        foreach ($array as $key => $item) {

            // Nested arrays will be merged in (non-recursively).
            if (is_array($item)) {
                $results = array_merge($results, $item); continue;
            }

            // Values with numeric keys will be appended in any case.
            if (is_int($key)) {
                $results[] = $item; continue;
            }

            // Non-numeric keys. If we've got the given key in $results already, it means it was merged
            // in from one of the nested arrays and those are meant to overwrite the initial values on collisions -
            // thus we're not going to do anything in that case.
            if (!array_key_exists($key, $results)) {
                $results[$key] = $item;
            }
        }

        return $results;
    }
public static function collapse ( array $ array ) : array { $ results = [ ] ; foreach ( $ array as $ key => $ item ) { // Nested arrays will be merged in (non-recursively). if ( is_array ( $ item ) ) { $ results = array_merge ( $ results , $ item ) ; continue ; } // Values with numeric keys will be appended in any case. if ( is_int ( $ key ) ) { $ results [ ] = $ item ; continue ; } // Non-numeric keys. If we've got the given key in $results already, it means it was merged // in from one of the nested arrays and those are meant to overwrite the initial values on collisions - // thus we're not going to do anything in that case. if ( ! array_key_exists ( $ key , $ results ) ) { $ results [ $ key ] = $ item ; } } return $ results ; }
Collapses an array of arrays into a single array. Not recursive, ie. only the first dimension of arrays
will be collapsed down.

Standard array_merge() rules apply - @link http://php.net/manual/en/function.array-merge.php -
non-array values with numeric keys will be appended to the resulting array in the order they are given, while
non-array values with non-numeric keys will have their keys preserved but the values may be overwritten by
the nested arrays being collapsed down if those contain values with the same non-numeric keys. Latter arrays
overwrite previous arrays' keys on collisions.

@param   array   $array  The array to collapse.
@return  array           The resulting array.
Collapses an array of arrays into a single array . Not recursive ie . only the first dimension of arrays will be collapsed down .