Calculate # of Rowspans and Colspans based on keys in a Multi-Array

I have these 2 types of layouts, basically, it can be any layout really. I have decided to use tables for this, since 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

This would return the $layout array like so:


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

Ok, this layout type would now return the following:


Again, there are some that are NOT SET in here:


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]); 
            // 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:


Need Your Help

Dir() function not working in Mac Excel 2011 VBA

excel vba excel-vba excel-vba-mac

Hi I am trying to list all the files in a subdirectory of where the Excel workbook is residing in. For some reason, the code cannot execute beyond the Dir function. Can anyone please advise? Thank ...

Catchable Fatal Error: Object of class Proxies\__CG__\AppBundle\Entity\Ticket could not be converted to string

php symfony relationship

I have an issue on my project using Symfony2. Is a 'worklog' project, with tickets(issues) for a specific project. But when I try to edit a worklog entry I have this error :