3v4l.org

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

Function combs:
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/GgFKA
function name:  combs
number of ops:  36
compiled vars:  !0 = $arr, !1 = $combs, !2 = $cntArr, !3 = $i, !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        COUNT                                            ~9      !0
         10        ASSIGN                                                   !2, ~9
    7    11        ASSIGN                                                   !3, 1
         12      > JMP                                                      ->32
    8    13    >   SUB                                              ~12     !2, !3
         14        ASSIGN                                                   !4, ~12
         15      > JMP                                                      ->29
    9    16    >   INIT_FCALL                                               'implode'
         17        SEND_VAL                                                 '%2C+'
         18        INIT_FCALL                                               'array_slice'
         19        SEND_VAR                                                 !0
         20        SEND_VAR                                                 !3
         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
    8    28        PRE_DEC                                                  !4
         29    >   IS_SMALLER                                               0, !4
         30      > JMPNZ                                                    ~19, ->16
    7    31    >   PRE_INC                                                  !3
         32    >   IS_SMALLER                                               !3, !2
         33      > JMPNZ                                                    ~21, ->13
   12    34    > > RETURN                                                   !1
   13    35*     > RETURN                                                   null

End of function combs

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.96 ms | 1403 KiB | 22 Q