petemc / transpose
A utility package adding a transpose function to multi-dimensional arrays, interchanging array indices.
v1.0.0
2016-06-07 13:54 UTC
Requires (Dev)
- phpunit/phpunit: ^5.4
This package is auto-updated.
Last update: 2024-12-17 10:26:21 UTC
README
transpose
Adds transpose function for multi-dimensional arrays, interchanging row/column indices.
Example
<?php use function PeteMc\Transpose\transpose; $input = [ 'names' => ['adam', 'ben', 'claire'], 'ages' => [24, 32, 52], 'emails' => ['adam@example.com', 'ben@example.com', 'claire@example.com'], ]; $transposed = transpose($input); /* $transposed is equal to [ ['adam', 24, 'adam@example.com'], ['ben', 32, 'ben@example.com'], ['claire', 52, 'claire@example.com'], ]; */