3v4l.org

run code in 300+ PHP versions simultaneously
<?php function comb($arr) { $combs = array_fill(0, count($arr)+1, array()); for ($i = 0, $n = count($arr); $i < $n; ++$i) { for ($j = $n-$i; $j > 0; --$j) { $combs[$j][] = implode(', ', array_slice($arr, $i, $j)); } } return $combs; } $arr = array('a', 'b', 'c', 'd', 'e', 'f'); var_dump(comb($arr));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fD1aX
function name:  (null)
number of ops:  8
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   15     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'comb'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function comb:
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 = 13
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 16
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 13
Branch analysis from position: 34
Branch analysis from position: 13
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 16
Branch analysis from position: 31
Branch analysis from position: 16
filename:       /in/fD1aX
function name:  comb
number of ops:  36
compiled vars:  !0 = $arr, !1 = $combs, !2 = $i, !3 = $n, !4 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'array_fill'
          2        SEND_VAL                                                 0
          3        COUNT                                            ~5      !0
          4        ADD                                              ~6      ~5, 1
          5        SEND_VAL                                                 ~6
          6        SEND_VAL                                                 <array>
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !1, $7
    6     9        ASSIGN                                                   !2, 0
         10        COUNT                                            ~10     !0
         11        ASSIGN                                                   !3, ~10
         12      > JMP                                                      ->32
    7    13    >   SUB                                              ~12     !3, !2
         14        ASSIGN                                                   !4, ~12
         15      > JMP                                                      ->29
    8    16    >   INIT_FCALL                                               'implode'
         17        SEND_VAL                                                 '%2C+'
         18        INIT_FCALL                                               'array_slice'
         19        SEND_VAR                                                 !0
         20        SEND_VAR                                                 !2
         21        SEND_VAR                                                 !4
         22        DO_ICALL                                         $16     
         23        SEND_VAR                                                 $16
         24        DO_ICALL                                         $17     
         25        FETCH_DIM_W                                      $14     !1, !4
         26        ASSIGN_DIM                                               $14
         27        OP_DATA                                                  $17
    7    28        PRE_DEC                                                  !4
         29    >   IS_SMALLER                                               0, !4
         30      > JMPNZ                                                    ~19, ->16
    6    31    >   PRE_INC                                                  !2
         32    >   IS_SMALLER                                               !2, !3
         33      > JMPNZ                                                    ~21, ->13
   11    34    > > RETURN                                                   !1
   12    35*     > RETURN                                                   null

End of function comb

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.21 ms | 1403 KiB | 22 Q