3v4l.org

run code in 300+ PHP versions simultaneously
<?php $storeSchedule = [ 'Sun' => [['12:00' => '01:00', '10:00' => '12:00']], 'Mon' => [['09:00' => '12:00']], 'Tue' => [['09:00' => '12:00']], 'Wed' => [['09:00' => '12:00']], 'Thu' => [['09:00' => '12:00'], ['22:50' => '23:00']], 'Fri' => [['09:00' => '12:00']], 'Sat' => [['12:00' => '01:00', '09:00' => '12:00']] ]; $today = date("D"); $closed = Null; foreach($storeSchedule[$today] as $opentimes){ foreach($opentimes as $open => $close){ $now = time(); if($now > strtotime(date("Y-m-d" . $open)) && $now < strtotime(date("Y-m-d" . $close))){ echo "store open now"; $closed = false; }else if($now < strtotime(date("Y-m-d" . $open))){ echo "store will open at " . date("Y-m-d" . $open); $closed = false; }else{ // Store is closed if($closed !== false) $closed = true; } } } if($closed){ // Dump the next open time var_dump($storeSchedule[date("D",strtotime($today)+86400)]); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 60
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 60
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 58
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 58
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 33
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 37
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 54
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 57
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 57
Branch analysis from position: 33
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 58
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 74
Branch analysis from position: 62
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 74
Branch analysis from position: 60
filename:       /in/DAvmo
function name:  (null)
number of ops:  75
compiled vars:  !0 = $storeSchedule, !1 = $today, !2 = $closed, !3 = $opentimes, !4 = $close, !5 = $open, !6 = $now
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        INIT_FCALL                                               'date'
          2        SEND_VAL                                                 'D'
          3        DO_ICALL                                         $8      
          4        ASSIGN                                                   !1, $8
   13     5        ASSIGN                                                   !2, null
   14     6        FETCH_DIM_R                                      ~11     !0, !1
          7      > FE_RESET_R                                       $12     ~11, ->60
          8    > > FE_FETCH_R                                               $12, !3, ->60
   15     9    > > FE_RESET_R                                       $13     !3, ->58
         10    > > FE_FETCH_R                                       ~14     $13, !4, ->58
         11    >   ASSIGN                                                   !5, ~14
   16    12        INIT_FCALL                                               'time'
         13        DO_ICALL                                         $16     
         14        ASSIGN                                                   !6, $16
   18    15        INIT_FCALL                                               'strtotime'
         16        INIT_FCALL                                               'date'
         17        CONCAT                                           ~18     'Y-m-d', !5
         18        SEND_VAL                                                 ~18
         19        DO_ICALL                                         $19     
         20        SEND_VAR                                                 $19
         21        DO_ICALL                                         $20     
         22        IS_SMALLER                                       ~21     $20, !6
         23      > JMPZ_EX                                          ~21     ~21, ->33
         24    >   INIT_FCALL                                               'strtotime'
         25        INIT_FCALL                                               'date'
         26        CONCAT                                           ~22     'Y-m-d', !4
         27        SEND_VAL                                                 ~22
         28        DO_ICALL                                         $23     
         29        SEND_VAR                                                 $23
         30        DO_ICALL                                         $24     
         31        IS_SMALLER                                       ~25     !6, $24
         32        BOOL                                             ~21     ~25
         33    > > JMPZ                                                     ~21, ->37
   19    34    >   ECHO                                                     'store+open+now'
   20    35        ASSIGN                                                   !2, <false>
   18    36      > JMP                                                      ->57
   21    37    >   INIT_FCALL                                               'strtotime'
         38        INIT_FCALL                                               'date'
         39        CONCAT                                           ~27     'Y-m-d', !5
         40        SEND_VAL                                                 ~27
         41        DO_ICALL                                         $28     
         42        SEND_VAR                                                 $28
         43        DO_ICALL                                         $29     
         44        IS_SMALLER                                               !6, $29
         45      > JMPZ                                                     ~30, ->54
   22    46    >   INIT_FCALL                                               'date'
         47        CONCAT                                           ~31     'Y-m-d', !5
         48        SEND_VAL                                                 ~31
         49        DO_ICALL                                         $32     
         50        CONCAT                                           ~33     'store+will+open+at+', $32
         51        ECHO                                                     ~33
   23    52        ASSIGN                                                   !2, <false>
   21    53      > JMP                                                      ->57
   26    54    >   TYPE_CHECK                                  1018          !2
         55      > JMPZ                                                     ~35, ->57
         56    >   ASSIGN                                                   !2, <true>
   15    57    > > JMP                                                      ->10
         58    >   FE_FREE                                                  $13
   14    59      > JMP                                                      ->8
         60    >   FE_FREE                                                  $12
   31    61      > JMPZ                                                     !2, ->74
   33    62    >   INIT_FCALL                                               'var_dump'
         63        INIT_FCALL                                               'date'
         64        SEND_VAL                                                 'D'
         65        INIT_FCALL                                               'strtotime'
         66        SEND_VAR                                                 !1
         67        DO_ICALL                                         $37     
         68        ADD                                              ~38     $37, 86400
         69        SEND_VAL                                                 ~38
         70        DO_ICALL                                         $39     
         71        FETCH_DIM_R                                      ~40     !0, $39
         72        SEND_VAL                                                 ~40
         73        DO_ICALL                                                 
   34    74    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.17 ms | 1022 KiB | 17 Q