3v4l.org

run code in 300+ PHP versions simultaneously
<?php function contains($start, $end, $check) { return $check > $start && $check < $end; } function overlap($a, $b) { return contains($a[0], $a[1], $b[0]) || contains($a[0], $a[1], $b[1]); } function checkListForOverlaps($list) { for($i=0,$c=count($list); $i<$c; ++$i) { for($j=$i+1; $j<$c; ++$j) { if( overlap($list[$i], $list[$j]) ) { printf("%s and %s overlap\n", json_encode($list[$i]), json_encode($list[$j])); } } } } $input = [[1, 3],[3, 7],[9,INF], [2, 5]]; checkListForOverlaps($input);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uR8JG
function name:  (null)
number of ops:  5
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                   !0, <array>
   22     1        INIT_FCALL                                               'checklistforoverlaps'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Function contains:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/uR8JG
function name:  contains
number of ops:  9
compiled vars:  !0 = $start, !1 = $end, !2 = $check
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3        IS_SMALLER                                       ~3      !0, !2
          4      > JMPZ_EX                                          ~3      ~3, ->7
          5    >   IS_SMALLER                                       ~4      !2, !1
          6        BOOL                                             ~3      ~4
          7    > > RETURN                                                   ~3
    5     8*     > RETURN                                                   null

End of function contains

Function overlap:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/uR8JG
function name:  overlap
number of ops:  22
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        INIT_FCALL                                               'contains'
          3        FETCH_DIM_R                                      ~2      !0, 0
          4        SEND_VAL                                                 ~2
          5        FETCH_DIM_R                                      ~3      !0, 1
          6        SEND_VAL                                                 ~3
          7        FETCH_DIM_R                                      ~4      !1, 0
          8        SEND_VAL                                                 ~4
          9        DO_FCALL                                      0  $5      
         10      > JMPNZ_EX                                         ~6      $5, ->20
         11    >   INIT_FCALL                                               'contains'
         12        FETCH_DIM_R                                      ~7      !0, 0
         13        SEND_VAL                                                 ~7
         14        FETCH_DIM_R                                      ~8      !0, 1
         15        SEND_VAL                                                 ~8
         16        FETCH_DIM_R                                      ~9      !1, 1
         17        SEND_VAL                                                 ~9
         18        DO_FCALL                                      0  $10     
         19        BOOL                                             ~6      $10
         20    > > RETURN                                                   ~6
    9    21*     > RETURN                                                   null

End of function overlap

Function checklistforoverlaps:
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 = 34, Position 2 = 5
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 8
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 5
Branch analysis from position: 34
Branch analysis from position: 5
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 28
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 8
Branch analysis from position: 31
Branch analysis from position: 8
Branch analysis from position: 28
filename:       /in/uR8JG
function name:  checkListForOverlaps
number of ops:  35
compiled vars:  !0 = $list, !1 = $i, !2 = $c, !3 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        ASSIGN                                                   !1, 0
          2        COUNT                                            ~5      !0
          3        ASSIGN                                                   !2, ~5
          4      > JMP                                                      ->32
   13     5    >   ADD                                              ~7      !1, 1
          6        ASSIGN                                                   !3, ~7
          7      > JMP                                                      ->29
   14     8    >   INIT_FCALL                                               'overlap'
          9        FETCH_DIM_R                                      ~9      !0, !1
         10        SEND_VAL                                                 ~9
         11        FETCH_DIM_R                                      ~10     !0, !3
         12        SEND_VAL                                                 ~10
         13        DO_FCALL                                      0  $11     
         14      > JMPZ                                                     $11, ->28
   15    15    >   INIT_FCALL                                               'printf'
         16        SEND_VAL                                                 '%25s+and+%25s+overlap%0A'
         17        INIT_FCALL                                               'json_encode'
         18        FETCH_DIM_R                                      ~12     !0, !1
         19        SEND_VAL                                                 ~12
         20        DO_ICALL                                         $13     
         21        SEND_VAR                                                 $13
         22        INIT_FCALL                                               'json_encode'
         23        FETCH_DIM_R                                      ~14     !0, !3
         24        SEND_VAL                                                 ~14
         25        DO_ICALL                                         $15     
         26        SEND_VAR                                                 $15
         27        DO_ICALL                                                 
   13    28    >   PRE_INC                                                  !3
         29    >   IS_SMALLER                                               !3, !2
         30      > JMPNZ                                                    ~18, ->8
   12    31    >   PRE_INC                                                  !1
         32    >   IS_SMALLER                                               !1, !2
         33      > JMPNZ                                                    ~20, ->5
   19    34    > > RETURN                                                   null

End of function checklistforoverlaps

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.46 ms | 1407 KiB | 21 Q