Group dates in a foreach loop

前端 未结 3 698
日久生厌
日久生厌 2021-01-15 04:54

I want to add a new line in order to group dates within a foreach loop.

Example:

2015-11-05
2015-11-05

2015-11-07

2015-11-10
2015-11-1         


        
3条回答
  •  野的像风
    2021-01-15 05:36

    $temp="":
    foreach($rows AS $row) {
            $my_date = $row['datetime_published'];
            echo $my_date.'
    '; if(strcmp($my_date,$temp)==0) echo '
    '; $temp = $my_date; }

提交回复
热议问题