I want to rotate a matrix 90 degrees clockwise. This amounts to making the first column in the input the first row of the output, the second column of the input the 2nd row of the output, and the 3rd column of the input the 3rd row of the output. Note that the bottom of the column=the beginning of the row, because of the 90 degree rotation.
For example:
$matrix= [[1, 2, 3]
[4, 5, 6],
[7, 8, 9]];
rotate90degrees($matrix)= [[7, 4, 1],
[8, 5, 2],
[9, 6, 3]]
What I know is I have first transpose the matrix and then swap the columns to rotate the matrix by 90 degrees. How can this be applied to php?