So I'm trying to render a table using php (in this case laravel blade templating engine). The idea is that when you have a date time who is equal to its next item_date it would colspan.
I've been able to get it to work with a colspan of 2
@if ($index != $timesheetweeks.length() - 1 && $timesheetweek[$index]['start_date'] == $timesheetweek[$index + 1]['start_date'])
<td colspan="2">{{{ $timesheetweek->start_date }}}</td>
@elseif ($index != 0 && $timesheetweek[$index]['start_date'] == $timesheetweek[$index - 1]['start_date'])
@else
<td>{{{ $timesheetweek->start_date }}}</td>
@endif
But what if you have 3 or more?
I would say try to place this logic in your controller and pass the elements to the view with a format like:
elements [
1 => element1,
2 => array(
element2,
element3
),
3 => element4
]
Where element 2 and 3 shares the same 'start_date'.
In your view:
// foreach ( ... as element )
@if ( is_array($element) )
// found some share dates
// td colspan=count($element)
@else
// no share
@endif