foreach ($orderItems as $item) {
if ($item->isNotCancelled()) {
echo 'ITEM....<br />';
// if last NOT CANCELLED item:
echo '<strong>ITEM....</strong><br />';
} else {
// ignored completely
}
}
I need to add <strong>
arround the last item which did not get cancelled... I know how to check the last item of an array or iterator, but with the condition in the if
case, how'd you do this?
Will I need 2 loops?
Update & Solution: I solved this by reversing the logic and to find the first item rather than the last.
I'll keep the question up if someone wants to comment or answer anyways.