Skip to content

Instantly share code, notes, and snippets.

@colindecarlo
Created February 13, 2016 17:16
Show Gist options
  • Save colindecarlo/55dfa89df7b06aa6d74e to your computer and use it in GitHub Desktop.
Save colindecarlo/55dfa89df7b06aa6d74e to your computer and use it in GitHub Desktop.
<?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