3v4l.org

run code in 300+ PHP versions simultaneously
<?php $period_start = '2016-01-01 00:00:00'; $period_end = '2016-01-31 23:59:59'; $uptime = []; $incidents = [ ['start' => '2016-01-05 00:00:00', 'end' => '2016-01-10 23:59:59'], ['start' => '2016-01-07 00:00:00', 'end' => '2016-01-15 23:59:59'], ['start' => '2016-01-20 00:00:00', 'end' => '2016-01-25 23:59:59'], ['start' => '2016-01-23 00:00:00', 'end' => '2016-01-24 23:59:59'] ]; if(strtotime($period_start) <= strtotime($incidents[0]['start'])) { array_push($uptime,['start' => $period_start, 'end' => $incidents[0]['start']]); } for($i=0;$i<sizeof($incidents);$i++) { if($incident[$i+1]) { if(strtotime($incident[$i]['end']) > strtotime($incident[$i+1]['start'])) { echo "sap"; } } } if(strtotime($period_end) >= strtotime($incidents[sizeof($incidents)-1]['end'])) { array_push($uptime,['start' => $incidents[0]['end'], 'end' => $period_end]); } print_r( $uptime );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 22
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 24
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 65
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 41
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 41
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 24
Branch analysis from position: 45
Branch analysis from position: 24
Branch analysis from position: 41
Branch analysis from position: 41
Branch analysis from position: 22
filename:       /in/XkoJW
function name:  (null)
number of ops:  69
compiled vars:  !0 = $period_start, !1 = $period_end, !2 = $uptime, !3 = $incidents, !4 = $i, !5 = $incident
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '2016-01-01+00%3A00%3A00'
    4     1        ASSIGN                                                   !1, '2016-01-31+23%3A59%3A59'
    6     2        ASSIGN                                                   !2, <array>
    8     3        ASSIGN                                                   !3, <array>
   15     4        INIT_FCALL                                               'strtotime'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $10     
          7        INIT_FCALL                                               'strtotime'
          8        FETCH_DIM_R                                      ~11     !3, 0
          9        FETCH_DIM_R                                      ~12     ~11, 'start'
         10        SEND_VAL                                                 ~12
         11        DO_ICALL                                         $13     
         12        IS_SMALLER_OR_EQUAL                                      $10, $13
         13      > JMPZ                                                     ~14, ->22
   16    14    >   INIT_FCALL                                               'array_push'
         15        SEND_REF                                                 !2
         16        INIT_ARRAY                                       ~15     !0, 'start'
         17        FETCH_DIM_R                                      ~16     !3, 0
         18        FETCH_DIM_R                                      ~17     ~16, 'start'
         19        ADD_ARRAY_ELEMENT                                ~15     ~17, 'end'
         20        SEND_VAL                                                 ~15
         21        DO_ICALL                                                 
   19    22    >   ASSIGN                                                   !4, 0
         23      > JMP                                                      ->42
   20    24    >   ADD                                              ~20     !4, 1
         25        FETCH_DIM_R                                      ~21     !5, ~20
         26      > JMPZ                                                     ~21, ->41
   21    27    >   INIT_FCALL                                               'strtotime'
         28        FETCH_DIM_R                                      ~22     !5, !4
         29        FETCH_DIM_R                                      ~23     ~22, 'end'
         30        SEND_VAL                                                 ~23
         31        DO_ICALL                                         $24     
         32        INIT_FCALL                                               'strtotime'
         33        ADD                                              ~25     !4, 1
         34        FETCH_DIM_R                                      ~26     !5, ~25
         35        FETCH_DIM_R                                      ~27     ~26, 'start'
         36        SEND_VAL                                                 ~27
         37        DO_ICALL                                         $28     
         38        IS_SMALLER                                               $28, $24
         39      > JMPZ                                                     ~29, ->41
   22    40    >   ECHO                                                     'sap'
   19    41    >   PRE_INC                                                  !4
         42    >   COUNT                                            ~31     !3
         43        IS_SMALLER                                               !4, ~31
         44      > JMPNZ                                                    ~32, ->24
   27    45    >   INIT_FCALL                                               'strtotime'
         46        SEND_VAR                                                 !1
         47        DO_ICALL                                         $33     
         48        INIT_FCALL                                               'strtotime'
         49        COUNT                                            ~34     !3
         50        SUB                                              ~35     ~34, 1
         51        FETCH_DIM_R                                      ~36     !3, ~35
         52        FETCH_DIM_R                                      ~37     ~36, 'end'
         53        SEND_VAL                                                 ~37
         54        DO_ICALL                                         $38     
         55        IS_SMALLER_OR_EQUAL                                      $38, $33
         56      > JMPZ                                                     ~39, ->65
   28    57    >   INIT_FCALL                                               'array_push'
         58        SEND_REF                                                 !2
         59        FETCH_DIM_R                                      ~40     !3, 0
         60        FETCH_DIM_R                                      ~41     ~40, 'end'
         61        INIT_ARRAY                                       ~42     ~41, 'start'
         62        ADD_ARRAY_ELEMENT                                ~42     !1, 'end'
         63        SEND_VAL                                                 ~42
         64        DO_ICALL                                                 
   31    65    >   INIT_FCALL                                               'print_r'
         66        SEND_VAR                                                 !2
         67        DO_ICALL                                                 
         68      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.98 ms | 1400 KiB | 19 Q