3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php for ($i = 1; $i <= 30; $i++) { $input = new \DateTime('2017-07-'.$i); $firstDayOfMonth = new \DateTime($input->format('Y-m-01')); $order = (int)($input->format('n') / 7) + 1; if (($input->format('N') % 7) <= ($firstDayOfMonth->format('N') % 7)) $order++; var_dump($order.' '.$input->format('l')); }
Output for 5.6.30, hhvm-3.15.4 - 3.22.0, 7.0.0 - 7.3.0rc3
string(11) "3 Saturday" string(9) "3 Sunday" string(9) "3 Monday" string(10) "3 Tuesday" string(12) "3 Wednesday" string(11) "3 Thursday" string(9) "3 Friday" string(11) "3 Saturday" string(9) "3 Sunday" string(9) "3 Monday" string(10) "3 Tuesday" string(12) "3 Wednesday" string(11) "3 Thursday" string(9) "3 Friday" string(11) "3 Saturday" string(9) "3 Sunday" string(9) "3 Monday" string(10) "3 Tuesday" string(12) "3 Wednesday" string(11) "3 Thursday" string(9) "3 Friday" string(11) "3 Saturday" string(9) "3 Sunday" string(9) "3 Monday" string(10) "3 Tuesday" string(12) "3 Wednesday" string(11) "3 Thursday" string(9) "3 Friday" string(11) "3 Saturday" string(9) "3 Sunday"