public static function collapse(array $array): array
    {
        $newArray = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                // strip any manually added '.'
                if (preg_match('/\./', (string) $key)) {
                    $key = substr($key, 0, -2);
                }

                self::recurseCollapse($value, $newArray, (array) $key);
            } else {
                $newArray[$key] = $value;
            }
        }

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

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                // strip any manually added '.'
                if (preg_match('/\./', (string) $key)) {
                    $key = substr($key, 0, -2);
                }

                self::recurseCollapse($value, $newArray, (array) $key);
            } else {
                $newArray[$key] = $value;
            }
        }

        return $newArray;
    }
public static function collapse ( array $ array ) : array { $ newArray = [ ] ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { // strip any manually added '.' if ( preg_match ( '/\./' , ( string ) $ key ) ) { $ key = substr ( $ key , 0 , - 2 ) ; } self :: recurseCollapse ( $ value , $ newArray , ( array ) $ key ) ; } else { $ newArray [ $ key ] = $ value ; } } return $ newArray ; }
Collapse a nested array down to an array of flat key=>value pairs.

@param array $array

@return array
Collapse a nested array down to an array of flat key = > value pairs .