3v4l.org

run code in 300+ PHP versions simultaneously
<?php $begin = new DateTime('2020-12-01'); $end = new DateTime('2021-01-01'); $row = array('monday' => 1, 'tuesday' => 0, 'wednesday' => 1, 'thursday' => 1, 'friday' => 1, 'saturday' => 0, 'sunday' => 1); $interval = new DateInterval('P1D'); $daterange = new DatePeriod($begin, $interval ,$end); $array = array(); foreach($daterange as $date){ if ($row[strtolower($date->format('l'))]) { $array[] = $date->format("D Y-m-d"); } } print_r($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 36
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 36
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 35
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/cgGUu
function name:  (null)
number of ops:  41
compiled vars:  !0 = $begin, !1 = $end, !2 = $row, !3 = $interval, !4 = $daterange, !5 = $array, !6 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $7      'DateTime'
          1        SEND_VAL_EX                                              '2020-12-01'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $7
    4     4        NEW                                              $10     'DateTime'
          5        SEND_VAL_EX                                              '2021-01-01'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $10
    6     8        ASSIGN                                                   !2, <array>
    8     9        NEW                                              $14     'DateInterval'
         10        SEND_VAL_EX                                              'P1D'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !3, $14
    9    13        NEW                                              $17     'DatePeriod'
         14        SEND_VAR_EX                                              !0
         15        SEND_VAR_EX                                              !3
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !4, $17
   10    19        ASSIGN                                                   !5, <array>
   11    20      > FE_RESET_R                                       $21     !4, ->36
         21    > > FE_FETCH_R                                               $21, !6, ->36
   12    22    >   INIT_FCALL                                               'strtolower'
         23        INIT_METHOD_CALL                                         !6, 'format'
         24        SEND_VAL_EX                                              'l'
         25        DO_FCALL                                      0  $22     
         26        SEND_VAR                                                 $22
         27        DO_ICALL                                         $23     
         28        FETCH_DIM_R                                      ~24     !2, $23
         29      > JMPZ                                                     ~24, ->35
   13    30    >   INIT_METHOD_CALL                                         !6, 'format'
         31        SEND_VAL_EX                                              'D+Y-m-d'
         32        DO_FCALL                                      0  $26     
         33        ASSIGN_DIM                                               !5
         34        OP_DATA                                                  $26
   11    35    > > JMP                                                      ->21
         36    >   FE_FREE                                                  $21
   16    37        INIT_FCALL                                               'print_r'
         38        SEND_VAR                                                 !5
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.5 ms | 1443 KiB | 15 Q