3v4l.org

run code in 300+ PHP versions simultaneously
<?php // suppose this is your mysql data, each inner pair is a 'to', 'from' $rows = array( array(1,6), array(7,10), array(8,12) ); list($a, $b) = current($rows); $downtime = $b - $a; while( list($c, $d) = next($rows) ) { $downtime += $d - $c - max(0, min($d,$b)-$c); if( $c >= $b ) $a = $c; $b = max($b,$d); } echo "total down time is " , $downtime; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 12
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 27
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 12
Branch analysis from position: 40
Branch analysis from position: 12
Branch analysis from position: 27
filename:       /in/Q2phs
function name:  (null)
number of ops:  43
compiled vars:  !0 = $rows, !1 = $a, !2 = $b, !3 = $downtime, !4 = $d, !5 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
   10     1        INIT_FCALL                                               'current'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $7      
          4        FETCH_LIST_R                                     $8      $7, 0
          5        ASSIGN                                                   !1, $8
          6        FETCH_LIST_R                                     $10     $7, 1
          7        ASSIGN                                                   !2, $10
          8        FREE                                                     $7
   11     9        SUB                                              ~12     !2, !1
         10        ASSIGN                                                   !3, ~12
   13    11      > JMP                                                      ->32
   15    12    >   SUB                                              ~14     !4, !5
         13        INIT_FCALL                                               'max'
         14        SEND_VAL                                                 0
         15        INIT_FCALL                                               'min'
         16        SEND_VAR                                                 !4
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                         $15     
         19        SUB                                              ~16     $15, !5
         20        SEND_VAL                                                 ~16
         21        DO_ICALL                                         $17     
         22        SUB                                              ~18     ~14, $17
         23        ASSIGN_OP                                     1          !3, ~18
   16    24        IS_SMALLER_OR_EQUAL                                      !2, !5
         25      > JMPZ                                                     ~20, ->27
   17    26    >   ASSIGN                                                   !1, !5
   18    27    >   INIT_FCALL                                               'max'
         28        SEND_VAR                                                 !2
         29        SEND_VAR                                                 !4
         30        DO_ICALL                                         $22     
         31        ASSIGN                                                   !2, $22
   13    32    >   INIT_FCALL                                               'next'
         33        SEND_REF                                                 !0
         34        DO_ICALL                                         $24     
         35        FETCH_LIST_R                                     $25     $24, 0
         36        ASSIGN                                                   !5, $25
         37        FETCH_LIST_R                                     $27     $24, 1
         38        ASSIGN                                                   !4, $27
         39      > JMPNZ                                                    $24, ->12
   21    40    >   ECHO                                                     'total+down+time+is+'
         41        ECHO                                                     !3
   23    42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.38 ms | 1008 KiB | 17 Q