3v4l.org

run code in 300+ PHP versions simultaneously
<?php $times = [ [ 'start' => '07:00', //started at 7 after midnight 'finish' => '15:00', //finished at 3 afternoon 'brake' => '01:30', //1 hour and 30 minutes of brake ], [ 'start' => '19:00', //started late afternoon 'finish' => '03:00', //finished at 3 after midnight 'brake' => '00:30', //30 minutes of brake ], ]; foreach($times as $time) { $start = $time['start']; $finish = $time['finish']; $break = $time['brake']; $startDate = \DateTime::createFromFormat('H:i', $start); $endDate = \DateTime::createFromFormat('H:i', $finish); if ($endDate < $startDate) { //end date is in the past, adjust ahead 24 hours $endDate->add(new \DateInterval('PT24H')); } $breakPeriod = new \DateInterval(vsprintf('PT%sH%sM', explode(':', $break))); $startDate->add($breakPeriod); $minutes = new \DateInterval('PT1M'); $datePeriods = new \DatePeriod($startDate, $minutes, $endDate); var_dump(iterator_count($datePeriods) / 60); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 60
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 60
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 27
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
filename:       /in/FsRbT
function name:  (null)
number of ops:  62
compiled vars:  !0 = $times, !1 = $time, !2 = $start, !3 = $finish, !4 = $break, !5 = $startDate, !6 = $endDate, !7 = $breakPeriod, !8 = $minutes, !9 = $datePeriods
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   17     1      > FE_RESET_R                                       $11     !0, ->60
          2    > > FE_FETCH_R                                               $11, !1, ->60
   18     3    >   FETCH_DIM_R                                      ~12     !1, 'start'
          4        ASSIGN                                                   !2, ~12
   19     5        FETCH_DIM_R                                      ~14     !1, 'finish'
          6        ASSIGN                                                   !3, ~14
   20     7        FETCH_DIM_R                                      ~16     !1, 'brake'
          8        ASSIGN                                                   !4, ~16
   22     9        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
         10        SEND_VAL                                                 'H%3Ai'
         11        SEND_VAR                                                 !2
         12        DO_FCALL                                      0  $18     
         13        ASSIGN                                                   !5, $18
   23    14        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
         15        SEND_VAL                                                 'H%3Ai'
         16        SEND_VAR                                                 !3
         17        DO_FCALL                                      0  $20     
         18        ASSIGN                                                   !6, $20
   24    19        IS_SMALLER                                               !6, !5
         20      > JMPZ                                                     ~22, ->27
   26    21    >   INIT_METHOD_CALL                                         !6, 'add'
         22        NEW                                              $23     'DateInterval'
         23        SEND_VAL_EX                                              'PT24H'
         24        DO_FCALL                                      0          
         25        SEND_VAR_NO_REF_EX                                       $23
         26        DO_FCALL                                      0          
   29    27    >   NEW                                              $26     'DateInterval'
         28        INIT_FCALL                                               'vsprintf'
         29        SEND_VAL                                                 'PT%25sH%25sM'
         30        INIT_FCALL                                               'explode'
         31        SEND_VAL                                                 '%3A'
         32        SEND_VAR                                                 !4
         33        DO_ICALL                                         $27     
         34        SEND_VAR                                                 $27
         35        DO_ICALL                                         $28     
         36        SEND_VAR_NO_REF_EX                                       $28
         37        DO_FCALL                                      0          
         38        ASSIGN                                                   !7, $26
   30    39        INIT_METHOD_CALL                                         !5, 'add'
         40        SEND_VAR_EX                                              !7
         41        DO_FCALL                                      0          
   32    42        NEW                                              $32     'DateInterval'
         43        SEND_VAL_EX                                              'PT1M'
         44        DO_FCALL                                      0          
         45        ASSIGN                                                   !8, $32
   33    46        NEW                                              $35     'DatePeriod'
         47        SEND_VAR_EX                                              !5
         48        SEND_VAR_EX                                              !8
         49        SEND_VAR_EX                                              !6
         50        DO_FCALL                                      0          
         51        ASSIGN                                                   !9, $35
   34    52        INIT_FCALL                                               'var_dump'
         53        INIT_FCALL                                               'iterator_count'
         54        SEND_VAR                                                 !9
         55        DO_ICALL                                         $38     
         56        DIV                                              ~39     $38, 60
         57        SEND_VAL                                                 ~39
         58        DO_ICALL                                                 
   17    59      > JMP                                                      ->2
         60    >   FE_FREE                                                  $11
   35    61      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.92 ms | 1013 KiB | 17 Q