flip horizontally, flip vertically
This function flips a m x n matrix using a horizontal or vertical axis.
The matrix must be rectangular. Consider filling short rows with blanks or zeros before flipping.
Indirect parameter passing is disabled
1
No. | Type | Description |
---|---|---|
1 input |
matrix | input matrix Matrix to be transposed |
Type | Description |
---|---|
matrix | Flipped matrix |
a[] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 } };
echo matrix( "0", 3, '|', 'a[] = ', a[] );
echo("Flip horizontally:");
h[] = flip horizontally( a[] );
echo matrix( "0", 3, '|', 'h[] = ', h[] );
echo("Flip vertically:");
v[] = flip vertically( a[] );
echo matrix( "0", 3, '|', 'v[] = ', v[] );
| 1 2 3|
| 4 5 6|
a[] = | 7 8 9|
| 10 11 12|
Flip horizontally:
| 3 2 1|
| 6 5 4|
h[] = | 9 8 7|
| 12 11 10|
Flip vertically:
| 10 11 12|
| 7 8 9|
v[] = | 4 5 6|
| 1 2 3|