3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getDaysInBetween($start, $end) { $weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]; $start_found = false; $days = []; while(true) { $next = next($weekdays); $day = (empty($day) || !$next)?reset($weekdays):$next; if($day === $start) $start_found = true; if($start_found) { $days[] = $day; if($day===$end && count($days)>1) return implode(", ",$days); } } } echo getDaysInBetween("Monday","Wednesday")."\n"; echo getDaysInBetween("Monday","Monday");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D5063
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'getdaysinbetween'
          1        SEND_VAL                                                 'Monday'
          2        SEND_VAL                                                 'Wednesday'
          3        DO_FCALL                                      0  $0      
          4        CONCAT                                           ~1      $0, '%0A'
          5        ECHO                                                     ~1
   27     6        INIT_FCALL                                               'getdaysinbetween'
          7        SEND_VAL                                                 'Monday'
          8        SEND_VAL                                                 'Monday'
          9        DO_FCALL                                      0  $2      
         10        ECHO                                                     $2
         11      > RETURN                                                   1

Function getdaysinbetween:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 6
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 47) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 25
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 39
Branch analysis from position: 26
2 jumps found. (Code = 46) Position 1 = 30, Position 2 = 33
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 39
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
Branch analysis from position: 33
Branch analysis from position: 39
Branch analysis from position: 25
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 25
Branch analysis from position: 24
Branch analysis from position: 25
Branch analysis from position: 14
filename:       /in/D5063
function name:  getDaysInBetween
number of ops:  41
compiled vars:  !0 = $start, !1 = $end, !2 = $weekdays, !3 = $start_found, !4 = $days, !5 = $next, !6 = $day
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ASSIGN                                                   !2, <array>
    7     3        ASSIGN                                                   !3, <false>
    9     4        ASSIGN                                                   !4, <array>
   11     5      > JMP                                                      ->39
   12     6    >   INIT_FCALL                                               'next'
          7        SEND_REF                                                 !2
          8        DO_ICALL                                         $10     
          9        ASSIGN                                                   !5, $10
   13    10        ISSET_ISEMPTY_CV                                 ~12     !6
         11      > JMPNZ_EX                                         ~12     ~12, ->14
         12    >   BOOL_NOT                                         ~13     !5
         13        BOOL                                             ~12     ~13
         14    > > JMPZ                                                     ~12, ->20
         15    >   INIT_FCALL                                               'reset'
         16        SEND_REF                                                 !2
         17        DO_ICALL                                         $14     
         18        QM_ASSIGN                                        ~15     $14
         19      > JMP                                                      ->21
         20    >   QM_ASSIGN                                        ~15     !5
         21    >   ASSIGN                                                   !6, ~15
   15    22        IS_IDENTICAL                                             !6, !0
         23      > JMPZ                                                     ~17, ->25
         24    >   ASSIGN                                                   !3, <true>
   17    25    > > JMPZ                                                     !3, ->39
   18    26    >   ASSIGN_DIM                                               !4
         27        OP_DATA                                                  !6
   19    28        IS_IDENTICAL                                     ~20     !6, !1
         29      > JMPZ_EX                                          ~20     ~20, ->33
         30    >   COUNT                                            ~21     !4
         31        IS_SMALLER                                       ~22     1, ~21
         32        BOOL                                             ~20     ~22
         33    > > JMPZ                                                     ~20, ->39
         34    >   INIT_FCALL                                               'implode'
         35        SEND_VAL                                                 '%2C+'
         36        SEND_VAR                                                 !4
         37        DO_ICALL                                         $23     
         38      > RETURN                                                   $23
   11    39    > > JMPNZ                                                    <true>, ->6
   24    40    > > RETURN                                                   null

End of function getdaysinbetween

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.24 ms | 1020 KiB | 18 Q