Adds transpose function for multi-dimensional arrays, interchanging row/column indices.
<?php
use function PeteMc\Transpose\transpose;
$input = [
'names' => ['adam', 'ben', 'claire'],
'ages' => [24, 32, 52],
'emails' => ['[email protected]', '[email protected]', '[email protected]'],
];
$transposed = transpose($input);
/*
$transposed is equal to
[
['adam', 24, '[email protected]'],
['ben', 32, '[email protected]'],
['claire', 52, '[email protected]'],
];
*/