3v4l.org

run code in 300+ PHP versions simultaneously
<?php function daysBetween($start_date, $end_date, $weekDay) { $first_date = strtotime($start_date." -1 days"); $first_date = strtotime(date("M d Y",$first_date)." next ".$weekDay); $last_date = strtotime($end_date." +1 days"); $last_date = strtotime(date("M d Y",$last_date)." last ".$weekDay); return floor(($last_date - $first_date)/(7*86400)) + 1; } print daysBetween("DEC 13 2005", "DEC 26 2005", "Monday");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gjNfR
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'daysbetween'
          1        SEND_VAL                                                 'DEC+13+2005'
          2        SEND_VAL                                                 'DEC+26+2005'
          3        SEND_VAL                                                 'Monday'
          4        DO_FCALL                                      0  $0      
          5        ECHO                                                     $0
          6      > RETURN                                                   1

Function daysbetween:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gjNfR
function name:  daysBetween
number of ops:  41
compiled vars:  !0 = $start_date, !1 = $end_date, !2 = $weekDay, !3 = $first_date, !4 = $last_date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3        INIT_FCALL                                               'strtotime'
          4        CONCAT                                           ~5      !0, '+-1+days'
          5        SEND_VAL                                                 ~5
          6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !3, $6
    5     8        INIT_FCALL                                               'strtotime'
          9        INIT_FCALL                                               'date'
         10        SEND_VAL                                                 'M+d+Y'
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                         $8      
         13        CONCAT                                           ~9      $8, '+next+'
         14        CONCAT                                           ~10     ~9, !2
         15        SEND_VAL                                                 ~10
         16        DO_ICALL                                         $11     
         17        ASSIGN                                                   !3, $11
    7    18        INIT_FCALL                                               'strtotime'
         19        CONCAT                                           ~13     !1, '+%2B1+days'
         20        SEND_VAL                                                 ~13
         21        DO_ICALL                                         $14     
         22        ASSIGN                                                   !4, $14
    8    23        INIT_FCALL                                               'strtotime'
         24        INIT_FCALL                                               'date'
         25        SEND_VAL                                                 'M+d+Y'
         26        SEND_VAR                                                 !4
         27        DO_ICALL                                         $16     
         28        CONCAT                                           ~17     $16, '+last+'
         29        CONCAT                                           ~18     ~17, !2
         30        SEND_VAL                                                 ~18
         31        DO_ICALL                                         $19     
         32        ASSIGN                                                   !4, $19
   10    33        INIT_FCALL                                               'floor'
         34        SUB                                              ~21     !4, !3
         35        DIV                                              ~22     ~21, 604800
         36        SEND_VAL                                                 ~22
         37        DO_ICALL                                         $23     
         38        ADD                                              ~24     $23, 1
         39      > RETURN                                                   ~24
   11    40*     > RETURN                                                   null

End of function daysbetween

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.3 ms | 1403 KiB | 20 Q