3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = Array ( '0' => Array ( 'start' => '2019-05-08 07:00:00', 'end' => '2019-05-08 17:00:00' ), '1' => Array ( 'start' => '2019-05-09 11:25:00', 'end' => '2019-05-09 12:40:00' ), '2' => Array ( 'start' => '2019-05-09 14:15:00', 'end' => '2019-05-09 14:30:00' ), '3' => Array ( 'start' => '2019-05-10 07:00:00', 'end' => '2019-05-10 17:00:00' ), '4' => Array ( 'start' => '2019-05-09 07:00:00', 'end' => '2019-05-09 07:40:00' ), '5' => Array ( 'start' => '2019-05-11 07:00:00', 'end' => '2019-05-11 17:00:00' ) ); $res=[]; foreach($arr as $k => $v){ $diff = strtotime($v['end'])-strtotime($v['start']); if($diff >= 7200){ for($i=strtotime($v['start']);$i<strtotime($v['end']);){ $start = date('Y-m-d H:i:s',$i); $i = $i+7200; $end = date('Y-m-d H:i:s',$i); $res[$k][] = [ 'start' => $start, 'end' => $end ]; } }else{ $res[$k][] = [ 'start' => date('Y-m-d H:i:s',strtotime($v['start'])), 'end' => date('Y-m-d H:i:s',strtotime($v['end'])) ]; } } echo '<pre>'; print_r($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 69
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 69
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 47
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 23
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 23
Branch analysis from position: 46
Branch analysis from position: 23
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 69
filename:       /in/TUcqb
function name:  (null)
number of ops:  75
compiled vars:  !0 = $arr, !1 = $res, !2 = $v, !3 = $k, !4 = $diff, !5 = $i, !6 = $start, !7 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   41     1        ASSIGN                                                   !1, <array>
   42     2      > FE_RESET_R                                       $10     !0, ->69
          3    > > FE_FETCH_R                                       ~11     $10, !2, ->69
          4    >   ASSIGN                                                   !3, ~11
   43     5        INIT_FCALL                                               'strtotime'
          6        FETCH_DIM_R                                      ~13     !2, 'end'
          7        SEND_VAL                                                 ~13
          8        DO_ICALL                                         $14     
          9        INIT_FCALL                                               'strtotime'
         10        FETCH_DIM_R                                      ~15     !2, 'start'
         11        SEND_VAL                                                 ~15
         12        DO_ICALL                                         $16     
         13        SUB                                              ~17     $14, $16
         14        ASSIGN                                                   !4, ~17
   44    15        IS_SMALLER_OR_EQUAL                                      7200, !4
         16      > JMPZ                                                     ~19, ->47
   45    17    >   INIT_FCALL                                               'strtotime'
         18        FETCH_DIM_R                                      ~20     !2, 'start'
         19        SEND_VAL                                                 ~20
         20        DO_ICALL                                         $21     
         21        ASSIGN                                                   !5, $21
         22      > JMP                                                      ->40
   46    23    >   INIT_FCALL                                               'date'
         24        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         25        SEND_VAR                                                 !5
         26        DO_ICALL                                         $23     
         27        ASSIGN                                                   !6, $23
   47    28        ADD                                              ~25     !5, 7200
         29        ASSIGN                                                   !5, ~25
   48    30        INIT_FCALL                                               'date'
         31        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         32        SEND_VAR                                                 !5
         33        DO_ICALL                                         $27     
         34        ASSIGN                                                   !7, $27
   50    35        INIT_ARRAY                                       ~31     !6, 'start'
   51    36        ADD_ARRAY_ELEMENT                                ~31     !7, 'end'
   49    37        FETCH_DIM_W                                      $29     !1, !3
         38        ASSIGN_DIM                                               $29
   51    39        OP_DATA                                                  ~31
   45    40    >   INIT_FCALL                                               'strtotime'
         41        FETCH_DIM_R                                      ~32     !2, 'end'
         42        SEND_VAL                                                 ~32
         43        DO_ICALL                                         $33     
         44        IS_SMALLER                                               !5, $33
         45      > JMPNZ                                                    ~34, ->23
         46    > > JMP                                                      ->68
   56    47    >   INIT_FCALL                                               'date'
         48        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         49        INIT_FCALL                                               'strtotime'
         50        FETCH_DIM_R                                      ~37     !2, 'start'
         51        SEND_VAL                                                 ~37
         52        DO_ICALL                                         $38     
         53        SEND_VAR                                                 $38
         54        DO_ICALL                                         $39     
         55        INIT_ARRAY                                       ~40     $39, 'start'
   57    56        INIT_FCALL                                               'date'
         57        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         58        INIT_FCALL                                               'strtotime'
         59        FETCH_DIM_R                                      ~41     !2, 'end'
         60        SEND_VAL                                                 ~41
         61        DO_ICALL                                         $42     
         62        SEND_VAR                                                 $42
         63        DO_ICALL                                         $43     
         64        ADD_ARRAY_ELEMENT                                ~40     $43, 'end'
   55    65        FETCH_DIM_W                                      $35     !1, !3
         66        ASSIGN_DIM                                               $35
   57    67        OP_DATA                                                  ~40
   42    68    > > JMP                                                      ->3
         69    >   FE_FREE                                                  $10
   61    70        ECHO                                                     '%3Cpre%3E'
   62    71        INIT_FCALL                                               'print_r'
         72        SEND_VAR                                                 !1
         73        DO_ICALL                                                 
         74      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.99 ms | 1400 KiB | 19 Q