Reverse horizontal and vertical for a HTML table

Posted by porton on Programmers See other posts from Programmers or by porton
Published on 2013-11-06T14:32:40Z Indexed on 2013/11/06 16:10 UTC
Read the original article Hit count: 397

Filed under:
|
|

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.

© Programmers or respective owner

Related posts about php

Related posts about algorithms