Reverse horizontal and vertical for a HTML table
- by porton
There is a two-dimensional array describing a HTML table. Each element of the array consists of:
the cell content
rowspan
colspan
Every row of this two dimensional array corresponds to <td> cells of a <tr> of the table which my software should generate.
I need to "reverse" the array (interchange vertical and horizontal direction).
Insofar I considered algorithm based on this idea: make a rectangular matrix of the size of the table and store in every element of this matrix the corresponding index of the element of the above mentioned array. (Note that two elements of the matrix may be identical due rowspan/colspan.) Then I could use this matrix to calculate rowspan/colspan for the inverted table.
But this idea seems bad for me. Any other algorithms?
Note that I program in PHP.