How do I get the calendar started on Monday?

-2
     <?php
        function linha($semana){
            echo "<tr>";

            for ($i=0; $i<=6; $i++):
                if(isset($semana[$i])):
                    echo "<td>$semana[$i]</td>";
                else:
                    echo "<td> </td>";
                endif;

            endfor;

            echo "</tr>";
        }



        function calendario(){
            $dia = 1;
            $semana = array();
            while ($dia <= 31):
                array_push($semana,$dia);

                if(count($semana)== 7) :
                    linha($semana);
                    $semana = array();
                endif;

            $dia++;

            endwhile;

            linha($semana);

        }
     ?>
      <table border="1">
            <tr>
                 <th>Dom</th>
                 <th>Seg</th>
                 <th>Ter</th>
                 <th>Qua</th>
                 <th>Quin</th>
                 <th>Sex</th>
                 <th>Sáb</th>
            </tr>
           <?php calendario() ?>
      </table> 
    
asked by anonymous 06.07.2016 / 22:21

1 answer

0

You can get the first day of the week with date("d/m/Y H:i:s", strtotime(date("Y")."W".date("W"))); (Do not forget to set date_default_timezone_set() ).

    
06.07.2016 / 22:42