Created
February 13, 2016 17:16
-
-
Save colindecarlo/55dfa89df7b06aa6d74e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function transpose($matrix) { | |
$transposed = []; | |
for ($column = 0; $column < count($matrix[0]); $column++) { | |
$transposed[$column] = []; | |
for ($row = 0; $row < count($matrix); $row++) { | |
$transposed[$column][] = $matrix[$row][$column]; | |
} | |
} | |
return $transposed; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment