简体   繁体   中英

Understanding the code logic of Calendar PHP

Can someone help me understand the logic of this loop. I am new to php and making a calendar from tutorial. The logic of this if Condition is unclear to me. Here is the code

    if($running_day == 6):
        $calendar.= '</tr>';
        if(($day_counter+1) != $days_in_month):
            $calendar.= '<tr class="calendar-row">';
        endif;
        $running_day = -1;
        $days_in_this_week = 0;
    endif;

The hardest line to decrypt is:

$calendar.= '<tr class="calendar-row">';

Any help would be appreciated.

This code:

if(($day_counter+1) != $days_in_month):
        $calendar.= '<tr class="calendar-row">';
    endif;

Its actually creating a new row in your table when after adding 1 to day counter variable not equal to days in month variable.

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM