If four out of five people suffer from diarrhea does that mean the fifth one enjoys it?
If four out of five people suffer from diarrhea does that mean the fifth one enjoys it?
[a][b][c][d][e] [f][g][h][i][j] [k][l][m][n][o] [p][q][r][s][t]I've come up with a PHP function to rotate this array by 90, 180, or 270 degrees.
function rotate($array, $degrees){ if ($degrees != 90 && $degrees != -90 && $degrees != 180) { return $array; } $i = 0; while ($array[0][0]) { if ($degrees == 180) { while ($row[0]) { } $newArray[] = $newArrayRow; } else { for ($j = $arrsize; $j >= 0; $j--) { if ($degrees == 90) { } else { } } $i++; if ($degrees == 90) { } else { } } } return $newArray; }
rotate($oldArray, 90) returns:
[p][k][f][a] [q][l][g][b] [r][m][h][c] [s][n][i][d] [t][o][j][e]
rotate($oldArray, -90) returns:
[e][j][o][t] [d][i][n][s] [c][h][m][r] [b][g][l][q] [a][f][k][p]
rotate($oldArray, 180) returns:
[t][s][r][q][p] [o][n][m][l][k] [j][i][h][g][f] [e][d][c][b][a]In general, why would you need to rotate a 2-dimensional array?