3v4l.org

run code in 300+ PHP versions simultaneously
<?php // the month to render and day to highlight $today = new DateTime(); // we'll need these to check if we're at the day we need to highlight // or if we're rendering a date that's outside $today's month $currentDay = $today->format('j'); $currentMonth = $today->format('n'); $daysInCurrentMonth = $today->format('t'); // figure out what Monday needs to kick off our table $date = (clone $today)->modify('first day of this month'); if ($date->format('w') != 1) { $date->modify('previous monday'); } $shouldStopRendering = false; echo '<table border="1">' . PHP_EOL; while (!$shouldStopRendering) { $weekDay = $date->format('w'); $month = $date->format('n'); $day = $date->format('j'); // start a new table row every time we hit a Monday, note that // since we forced $date to be a Monday above, our table should // now always start with a <tr> if ($weekDay == 1) { echo ' <tr>' . PHP_EOL; } if ($month != $currentMonth) { // we're either at the beginning or end of our table echo ' <td>&nbsp;</td>' . PHP_EOL; } else if ($day == $currentDay) { // highlight the current date echo ' <td bgcolor="#ff0000">' . $day . '</td>' . PHP_EOL; } else { echo ' <td>' . $day . '</td>' . PHP_EOL; } if ($weekDay == 0) { // every time we hit a Sunday, close the current table row echo ' </tr>' . PHP_EOL; // on a Sunday, if we've gone outside the current month **or** // this Sunday happens to be the last day we need to render, // stop looping so we can close the table if ($month != $currentMonth || $day == $daysInCurrentMonth) { $shouldStopRendering = true; } } // move on to the next day we need to display $date->modify('+1 day'); } echo '</table>';
Output for git.master_jit, git.master, rfc.property-hooks
<table border="1"> <tr> <td>&nbsp;</td> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> <td>6</td> </tr> <tr> <td>7</td> <td>8</td> <td>9</td> <td>10</td> <td>11</td> <td>12</td> <td>13</td> </tr> <tr> <td>14</td> <td>15</td> <td>16</td> <td>17</td> <td>18</td> <td>19</td> <td>20</td> </tr> <tr> <td>21</td> <td bgcolor="#ff0000">22</td> <td>23</td> <td>24</td> <td>25</td> <td>26</td> <td>27</td> </tr> <tr> <td>28</td> <td>29</td> <td>30</td> <td>31</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> </table>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
99.13 ms | 407 KiB | 5 Q