How to get data column saperated in foreach loop

How to get data in different section like today upcoming and overdue date with the help of foreach loop..
How to get data in different section like today upcoming and overdue date with the help of foreach loop..

foreach($list as $index=>$row) { 

    $dueDt = new DateTime($row->due_timeDate);
    $todayDt = new DateTime('now');
    $due=$dueDt->format('Y-m-d');   
    $today=$todayDt->format('Y-m-d');  
      if($due==$today)  
      {


            echo $due.' Today' ;
            echo '<br>';
            $task['today'][]=$row;

      }else if($due>$today)
      {


            echo $due.' Upcoming'; 
            echo '<br>'; 
            $task['today'][]=$row;

      }else if($due<$today)
      {


            echo $due.' Overdue';; 
            echo '<br>';   
            $task['overdue'][]=$row;
      } 
}

my data is coming like this

2015-10-30 Upcoming
2015-10-29 Today
2015-10-28 Overdue
2015-10-28 Overdue
2015-10-27 Overdue
2015-10-27 Overdue
2015-10-15 Overdue

But want data like this from foreach loop

Upcoming
        2015-10-30 

Today
        2015-10-29 
Overdue
        2015-10-28 
        2015-10-28 
        2015-10-27 
        2015-10-27 
        2015-10-15 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s