3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ "Mon" => [ ["start" => "09:30", "end" => "11:00"] ], "Sun" => [ ["start" => "07:30", "end" => "08:00"], ["start" => "08:30", "end" => "09:30"], ["start" => "14:10", "end" => "23:59"] ] ]; function in_range($array) { $dayname = date("D"); if (!isset($array[$dayname])) { return false; // quick, 1st level return } $now = date("H:i"); foreach ($array[$dayname] as $range) { if ($now >= $range["start"] && $range["end"] >= $now) { return true; // quick return } } return false; // fallback return after iterating the dayname group } var_export(in_range($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OttIR
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   27     1        INIT_FCALL                                               'var_export'
          2        INIT_FCALL                                               'in_range'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function in_range:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 26
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 26
Branch analysis from position: 16
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 22
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/OttIR
function name:  in_range
number of ops:  29
compiled vars:  !0 = $array, !1 = $dayname, !2 = $now, !3 = $range
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        INIT_FCALL                                               'date'
          2        SEND_VAL                                                 'D'
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
   15     5        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !0, !1
          6        BOOL_NOT                                         ~7      ~6
          7      > JMPZ                                                     ~7, ->9
   16     8    > > RETURN                                                   <false>
   18     9    >   INIT_FCALL                                               'date'
         10        SEND_VAL                                                 'H%3Ai'
         11        DO_ICALL                                         $8      
         12        ASSIGN                                                   !2, $8
   19    13        FETCH_DIM_R                                      ~10     !0, !1
         14      > FE_RESET_R                                       $11     ~10, ->26
         15    > > FE_FETCH_R                                               $11, !3, ->26
   20    16    >   FETCH_DIM_R                                      ~12     !3, 'start'
         17        IS_SMALLER_OR_EQUAL                              ~13     ~12, !2
         18      > JMPZ_EX                                          ~13     ~13, ->22
         19    >   FETCH_DIM_R                                      ~14     !3, 'end'
         20        IS_SMALLER_OR_EQUAL                              ~15     !2, ~14
         21        BOOL                                             ~13     ~15
         22    > > JMPZ                                                     ~13, ->25
   21    23    >   FE_FREE                                                  $11
         24      > RETURN                                                   <true>
   19    25    > > JMP                                                      ->15
         26    >   FE_FREE                                                  $11
   24    27      > RETURN                                                   <false>
   25    28*     > RETURN                                                   null

End of function in_range

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.5 ms | 1019 KiB | 16 Q