3v4l.org

run code in 300+ PHP versions simultaneously
<?php $months = array( "Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември" ); $days_in_month = array( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ); $current_month_index = date("n") - 1; $day_of_the_month = date("j"); $day_of_the_week = date("w"); $day_of_the_week_difference = $day_of_the_week - $day_of_the_month % 7; $elements_in_calendar = array(); for ($i = 0; $i < $day_of_the_week_difference; $i++) { array_push($elements_in_calendar, ""); } for ($i = 1; $i <= $days_in_month[$current_month_index]; $i++) { array_push($elements_in_calendar, $i); } ?> <html> <head> <style> table, td { border: 1px solid #000; text-align: center; border-collapse: collapse; } </style> </head> <body> <table> <tr> <td colspan="2"><a href="#"><?php echo $months[$current_month_index - 1] ?></a></td> <td colspan="3"><?php echo $months[$current_month_index] ?></td> <td colspan="2"><a href="#"><?php echo $months[$current_month_index + 1] ?></a></td> </tr> <tr> <td>Понеделник</td> <td>Вторник</td> <td>Сряда</td> <td>Четвъртък</td> <td>Петък</td> <td>Събота</td> <td>Неделя</td> </tr> <?php echo $day_of_the_week_difference ?> <?php for ($i = 0; $i < count($elements_in_calendar); $i++) { ?> <?php if ($i % 7 === 1) { ?> <?php if ($i != 1) { ?> </tr> <?php } ?> <tr> <?php } ?> <td><?php echo $elements_in_calendar[$i] ?></td> <?php } ?> </tr> </table> </body> </html>

preferences:
36.35 ms | 402 KiB | 5 Q