src/Collection/CollectionFlattener.php
protected function flatCollection(array $data, string $prefix = null, array $flat_data = []): array
    {
        foreach ($data as $key => $val) {
            if ($prefix !== null) {
                $key = $prefix.$this->separator.$key;
            }

            $skip_key = $this->skipKey($key);

            if (is_array($val)) {
                $flat_data = array_merge(
                    $flat_data,
                    $this->flatCollection($val, (string) $key)
                );
                continue;
            }

            if ($skip_key) {
                continue;
            }

            $flat_data[$key] = $val;
        }

        return $flat_data;
    }
protected function flatCollection(array $data, string $prefix = null, array $flat_data = []): array
    {
        foreach ($data as $key => $val) {
            if ($prefix !== null) {
                $key = $prefix.$this->separator.$key;
            }

            $skip_key = $this->skipKey($key);

            if (is_array($val)) {
                $flat_data = array_merge(
                    $flat_data,
                    $this->flatCollection($val, (string) $key)
                );
                continue;
            }

            if ($skip_key) {
                continue;
            }

            $flat_data[$key] = $val;
        }

        return $flat_data;
    }
protected function flatCollection ( array $ data , string $ prefix = null , array $ flat_data = [ ] ) : array { foreach ( $ data as $ key => $ val ) { if ( $ prefix !== null ) { $ key = $ prefix . $ this -> separator . $ key ; } $ skip_key = $ this -> skipKey ( $ key ) ; if ( is_array ( $ val ) ) { $ flat_data = array_merge ( $ flat_data , $ this -> flatCollection ( $ val , ( string ) $ key ) ) ; continue ; } if ( $ skip_key ) { continue ; } $ flat_data [ $ key ] = $ val ; } return $ flat_data ; }
Flat collection recursively to one level key,val array
@param array $data
@param string|null  $prefix
@param array $flat_data
@return array
Flat collection recursively to one level key val array