I have these 2 types of layouts, basically, it can be any layout really. I have decided to use tables for this, sinc开发者_JAVA技巧e using div tags cause undesirable results in some possible layout types.
Here are 2 pics that describe the returned results of row and column:
alt text http://acs.graphicsmayhem.com/images/SimpleLayout.png
This would return the $layout array like so:
$layout[0][0]
$layout[0][1]
$layout[1][1]
In this layout type: $layout[1][0]
is NOT SET, or doesn't exist. Row 1, Column 0 doesn't exist in here. So how can we use this to help us determine the rowspans...?
alt text http://acs.graphicsmayhem.com/images/MoreComplexLayout.png
Ok, this layout type would now return the following:
$layout[0][0]
$layout[0][1]
$layout[1][0]
$layout[2][0]
$layout[2][1]
$layout[3][1]
Again, there are some that are NOT SET in here:
$layout[1][1]
$layout[3][0]
Ok, I have an array called $layout that does a foreach on the row and column, but it doesn't grab the rows and columns that are NOT SET. So I created a for loop (with the correct counts of how many rows there are and how many columns there are). Here's what I got so far:
// $not_set = array();
for($x = 0; $x < $cols; $x++)
{
$f = 0;
for($p = 0; $p < $rows; $p++)
{
// $f = count($layout[$p]);
if(!isset($layout[$p][$x]))
{
$f++;
// It could be a rowspan or a Colspan...
// We need to figure out which 1 it is!
/*
$not_set[] = array(
'row' => $p,
'column' => $x,
);
*/
}
// if ($rows - count($layout[$p]))
}
}
Ok, the $layout array has 2 keys. The first 1 is [ row ] and the 2nd key is [ column ]. Now looping through them all and determining whether it's NOT SET, tells me that either a rowspan or a colspan needs to be put into something somewhere. I'm completely lost here.
Basically, I would like to have an array returned here, something like this:
$spans['row'][ row # ][ column # ] = Number of rowspans for that <td> element.
$spans['column'][ row # ][ column # ] = Number of colspans for that <td> element.
It's either going to need a colspan or a rowspan, it will definitely never need both for the same <td>
element. Also, the pics above show for only 2 columns, there can be more than 2 columns.
Any help at all would be greatly appreciated!
Why not store the colspan & rowspan datum in the original array, rather than trying to derive them? Something like this:
$layout[0][0][1][1]
$layout[0][1][1][1]
$layout[1][0][2][1]
$layout[2][0][1][2]
$layout[2][1][1][1]
$layout[3][1][1][1]
精彩评论