public static function transpose(array $array): array
    {
        $new   = [];
        $keys  = array_keys($array);

        foreach ($keys as $k => $val) {
            foreach ((array) $array[$val] as $k2 => $v2) {
                $new[$k2][$val] = $v2;
            }
        }

        return $new;
    }
public static function transpose(array $array): array
    {
        $new   = [];
        $keys  = array_keys($array);

        foreach ($keys as $k => $val) {
            foreach ((array) $array[$val] as $k2 => $v2) {
                $new[$k2][$val] = $v2;
            }
        }

        return $new;
    }
public static function transpose ( array $ array ) : array { $ new = [ ] ; $ keys = array_keys ( $ array ) ; foreach ( $ keys as $ k => $ val ) { foreach ( ( array ) $ array [ $ val ] as $ k2 => $ v2 ) { $ new [ $ k2 ] [ $ val ] = $ v2 ; } } return $ new ; }
Transpose a two-dimensional matrix array.

@param  array $array An array with two level.

@return array An pivoted array.
Transpose a two - dimensional matrix array .