Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $order = 'asc'; // 'asc' or 'desc'
- foreach($turnovers as $i => $turnover) {
- // .....
- $currentDate = new DateTime($turnover->turnoverDate);
- $currentMonth = $currentDate->format('m');
- $nextDate = $turnover;
- // check if last item in array
- if ($i < count($turnovers) - 1 && $order === 'asc') {
- $nextDate = $turnovers[$i+1];
- } else if ($i > 0 && $order === 'desc') {
- $nextDate = $turnovers[$i-1];
- }
- $nextDate = new DateTime($nextDate->turnoverDate);
- $nextMonth = $nextDate->format('m');
- if($currentMonth != $nextMonth) {
- $print .= "<tr class=\"table-success\">";
- }
- else {
- $print .= "<tr>";
- }
- // ....
- }
Advertisement
Add Comment
Please, Sign In to add comment