Explain how this array transposing and flattening function works



PHP Snippet 1:

$a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
$b = ['a', 'b', 'c', 'd', 'e', 'f'];
$c = ['A', 'B'];

PHP Snippet 2:

$args = [$a, $b, $c];
count($args) = 3;

PHP Snippet 3:

$output = [1, 'a', 'A'];

PHP Snippet 4:

$a = [2, 3, 4, 5, 6, 7, 8, 9, 10];
$b = ['b', 'c', 'd', 'e', 'f'];
$c = ['B'];

PHP Snippet 5:

$a = [3, 4, 5, 6, 7, 8, 9, 10];
$b = ['c', 'd', 'e', 'f'];
$c = [];
$output = $output = [1, 'a', 'A', 2, 'b', 'B'];
//because $c is empty array_filter() removes it from $args
$args = [$a, $b];

PHP Snippet 6:

var_export(
    array_merge(
        ...array_map(
            fn(...$col) => array_filter(
                $col,
                fn($v) => !is_null($v)
            ),
            $a,
            $b,
            $c
        )
    )
);

PHP Snippet 7:

$output = [];
foreach ([$a, $b, $c] as $i => $array) {
    foreach ($array as $k => $v) {
        $output[$k][$i] = $v;
    }
}
var_export(implode(array_merge(...$output)));