3v4l.org

run code in 300+ PHP versions simultaneously
<?php function dates_in_consecutive_range(string $start_date, string $end_date, array $dates_list): bool { // If in consecutive range without missing days (holes), return true, else return false // If either $start_date or $end_date or both is not in $dates_list, return false return false; } $dates_list = [ '2022-03-11', '2022-03-12', '2022-03-13', '2022-03-14', '2022-03-18', '2022-03-19', ]; $start_date = '2022-03-11'; $end_date = '2022-03-14'; var_dump(dates_in_consecutive_range($start_date, $end_date, $dates_list)); // true $start_date = '2022-03-11'; $end_date = '2022-03-18'; var_dump(dates_in_consecutive_range($start_date, $end_date, $dates_list)); // false $start_date = '2022-03-18'; $end_date = '2022-03-19'; var_dump(dates_in_consecutive_range($start_date, $end_date, $dates_list)); // true $start_date = '2022-03-19'; $end_date = '2022-03-20'; var_dump(dates_in_consecutive_range($start_date, $end_date, $dates_list)); // false ($end_date not in $dates_list)
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hfk5D
function name:  (null)
number of ops:  42
compiled vars:  !0 = $dates_list, !1 = $start_date, !2 = $end_date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, <array>
   18     1        ASSIGN                                                   !1, '2022-03-11'
   19     2        ASSIGN                                                   !2, '2022-03-14'
   21     3        INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'dates_in_consecutive_range'
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !2
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                                 
   23    11        ASSIGN                                                   !1, '2022-03-11'
   24    12        ASSIGN                                                   !2, '2022-03-18'
   26    13        INIT_FCALL                                               'var_dump'
         14        INIT_FCALL                                               'dates_in_consecutive_range'
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !2
         17        SEND_VAR                                                 !0
         18        DO_FCALL                                      0  $10     
         19        SEND_VAR                                                 $10
         20        DO_ICALL                                                 
   28    21        ASSIGN                                                   !1, '2022-03-18'
   29    22        ASSIGN                                                   !2, '2022-03-19'
   31    23        INIT_FCALL                                               'var_dump'
         24        INIT_FCALL                                               'dates_in_consecutive_range'
         25        SEND_VAR                                                 !1
         26        SEND_VAR                                                 !2
         27        SEND_VAR                                                 !0
         28        DO_FCALL                                      0  $14     
         29        SEND_VAR                                                 $14
         30        DO_ICALL                                                 
   33    31        ASSIGN                                                   !1, '2022-03-19'
   34    32        ASSIGN                                                   !2, '2022-03-20'
   36    33        INIT_FCALL                                               'var_dump'
         34        INIT_FCALL                                               'dates_in_consecutive_range'
         35        SEND_VAR                                                 !1
         36        SEND_VAR                                                 !2
         37        SEND_VAR                                                 !0
         38        DO_FCALL                                      0  $18     
         39        SEND_VAR                                                 $18
         40        DO_ICALL                                                 
         41      > RETURN                                                   1

Function dates_in_consecutive_range:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hfk5D
function name:  dates_in_consecutive_range
number of ops:  6
compiled vars:  !0 = $start_date, !1 = $end_date, !2 = $dates_list
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    6     3      > RETURN                                                   <false>
    7     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function dates_in_consecutive_range

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.25 ms | 1012 KiB | 18 Q