I need some help figuring out this for loop logic. I know exactly what I want to do, but I sadly can’t seem to get to it.
This is my code at the moment.
<? foreach($ticket_details as $ticket): ?>
<tr class="tableBG" style="background-color: #fc6">
<td align="center"><?= $ticket['name']; ?></td>
<td align="center"><?= $ticket['price']; ?></td>
<td align="center"><?= $ticket['priceWithinAllocation']; ?></td>
<? for($i = 0; $i < $event_details['number_of_days']; $i++): ?>
<?
foreach($ticket['days'] as $key => $value)
{
if($value == date('Y-m-d', strtotime($event_details['startDate'] . "+ $i day")))
{
echo "<td>✓</td>";
}
else
{
echo "<td>--</td>";
}
}
?>
<? endfor; ?>
<td align='center'>
<input type='button' class='remove' id='remove[ticket][<?= $ticket['ticketID'] ?>]' value='REMOVE' />
</td>
</tr>
<? endforeach; ?>
This doesn’t really work.
My tickets array looks like this:
[5] => Array
(
[ticketID] => 5
[eventID] => 1
[name] => Thu
[price] => 500
[priceWithinAllocation] => 250
[day] => 2011-08-25
[days] => Array
(
[0] => 2011-08-25
)
)
[6] => Array
(
[ticketID] => 6
[eventID] => 1
[name] => Wed+Thu
[price] => 900
[priceWithinAllocation] => 110
[day] => 2011-08-24
[days] => Array
(
[0] => 2011-08-24
[1] => 2011-08-25
)
)
When $ticket['days'] contains more than one value, it prints out too many empty (–) <td>. I’m not sure how to do the loop without having it print more than I need. Here’s a screenshot of what happens with this code:

I tried some stuff with if(count($ticket['days'])) { } but that didn’t work out. So now I’m stuck.
I realise this is a fairly vague question because I didn’t provide too much code here; if needed, I can provide more, but there’s a lot of stuff going on so I kept it to a minimum.
Thanks in advance.
You print a cell for each date in $ticket[‘days’]. That’s why you get too much cells.
Try this :