3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calculateRoutes($points){ //our output array $out = array(); //reset the index of our points to ensure they are 0 to N-1 $points = array_values($points); //loop over the points once for($i=0; $i<count($points) - 1; $i++){ //loop over the points again, offset by 1 for($j=$i+1; $j<count($points); $j++){ //add to our output array the two points $out[] = array($points[$i], $points[$j]); } } //return the final result return $out; } $points = array('A', 'B', 'C', 'D'); $routes = calculateRoutes($points); print_r($routes);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cINuR
function name:  (null)
number of ops:  9
compiled vars:  !0 = $points, !1 = $routes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, <array>
   25     1        INIT_FCALL                                               'calculateroutes'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   27     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function calculateroutes:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 8
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 11
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 8
Branch analysis from position: 26
Branch analysis from position: 8
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 11
Branch analysis from position: 21
Branch analysis from position: 11
filename:       /in/cINuR
function name:  calculateRoutes
number of ops:  28
compiled vars:  !0 = $points, !1 = $out, !2 = $i, !3 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
    8     2        INIT_FCALL                                               'array_values'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !0, $5
   11     6        ASSIGN                                                   !2, 0
          7      > JMP                                                      ->22
   13     8    >   ADD                                              ~8      !2, 1
          9        ASSIGN                                                   !3, ~8
         10      > JMP                                                      ->18
   15    11    >   FETCH_DIM_R                                      ~11     !0, !2
         12        INIT_ARRAY                                       ~12     ~11
         13        FETCH_DIM_R                                      ~13     !0, !3
         14        ADD_ARRAY_ELEMENT                                ~12     ~13
         15        ASSIGN_DIM                                               !1
         16        OP_DATA                                                  ~12
   13    17        PRE_INC                                                  !3
         18    >   COUNT                                            ~15     !0
         19        IS_SMALLER                                               !3, ~15
         20      > JMPNZ                                                    ~16, ->11
   11    21    >   PRE_INC                                                  !2
         22    >   COUNT                                            ~18     !0
         23        SUB                                              ~19     ~18, 1
         24        IS_SMALLER                                               !2, ~19
         25      > JMPNZ                                                    ~20, ->8
   20    26    > > RETURN                                                   !1
   21    27*     > RETURN                                                   null

End of function calculateroutes

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.36 ms | 1006 KiB | 16 Q