3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ["start" => "Mon 09:30", "end" => "Mon 11:00"], ["start" => "Sun 14:10", "end" => "Sun 20:00"], ["start" => "Sun 07:30", "end" => "Sun 08:00"], ["start" => "Sun 08:30", "end" => "Sun 09:30"] ]; function in_range($array) { $now = time(); // using server timezone echo date("D H:i") , "\n"; foreach ($array as $range) { if ($now >= strtotime($range["start"]) && strtotime($range["end"]) >= $now) { return $range; // or true if you like } } return false; } var_export(in_range($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1U5Pn
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>
   20     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 = 77) Position 1 = 10, Position 2 = 27
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 27
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 23
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/1U5Pn
function name:  in_range
number of ops:  30
compiled vars:  !0 = $array, !1 = $now, !2 = $range
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'time'
          2        DO_ICALL                                         $3      
          3        ASSIGN                                                   !1, $3
   11     4        INIT_FCALL                                               'date'
          5        SEND_VAL                                                 'D+H%3Ai'
          6        DO_ICALL                                         $5      
          7        ECHO                                                     $5
          8        ECHO                                                     '%0A'
   12     9      > FE_RESET_R                                       $6      !0, ->27
         10    > > FE_FETCH_R                                               $6, !2, ->27
   13    11    >   INIT_FCALL                                               'strtotime'
         12        FETCH_DIM_R                                      ~7      !2, 'start'
         13        SEND_VAL                                                 ~7
         14        DO_ICALL                                         $8      
         15        IS_SMALLER_OR_EQUAL                              ~9      $8, !1
         16      > JMPZ_EX                                          ~9      ~9, ->23
         17    >   INIT_FCALL                                               'strtotime'
         18        FETCH_DIM_R                                      ~10     !2, 'end'
         19        SEND_VAL                                                 ~10
         20        DO_ICALL                                         $11     
         21        IS_SMALLER_OR_EQUAL                              ~12     !1, $11
         22        BOOL                                             ~9      ~12
         23    > > JMPZ                                                     ~9, ->26
   14    24    >   FE_FREE                                                  $6
         25      > RETURN                                                   !2
   12    26    > > JMP                                                      ->10
         27    >   FE_FREE                                                  $6
   17    28      > RETURN                                                   <false>
   18    29*     > RETURN                                                   null

End of function in_range

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.66 ms | 1021 KiB | 18 Q