3v4l.org

run code in 300+ PHP versions simultaneously
<?php function combs($arr) { $result = array(); $cntArr = count($arr); for ($i = 0; $i < $cntArr; ++$i) { for ($j = $cntArr-$i; $j > 0; --$j) { $result[$j][] = implode(', ', array_slice($arr, $i, $j)); } } array_shift($result); return $result; } $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/qBbA5
function name:  (null)
number of ops:  8
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, <array>
   17     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 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 6
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 9
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 6
Branch analysis from position: 27
Branch analysis from position: 6
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 9
Branch analysis from position: 24
Branch analysis from position: 9
filename:       /in/qBbA5
function name:  combs
number of ops:  32
compiled vars:  !0 = $arr, !1 = $result, !2 = $cntArr, !3 = $i, !4 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
    6     2        COUNT                                            ~6      !0
          3        ASSIGN                                                   !2, ~6
    7     4        ASSIGN                                                   !3, 0
          5      > JMP                                                      ->25
    8     6    >   SUB                                              ~9      !2, !3
          7        ASSIGN                                                   !4, ~9
          8      > JMP                                                      ->22
    9     9    >   INIT_FCALL                                               'implode'
         10        SEND_VAL                                                 '%2C+'
         11        INIT_FCALL                                               'array_slice'
         12        SEND_VAR                                                 !0
         13        SEND_VAR                                                 !3
         14        SEND_VAR                                                 !4
         15        DO_ICALL                                         $13     
         16        SEND_VAR                                                 $13
         17        DO_ICALL                                         $14     
         18        FETCH_DIM_W                                      $11     !1, !4
         19        ASSIGN_DIM                                               $11
         20        OP_DATA                                                  $14
    8    21        PRE_DEC                                                  !4
         22    >   IS_SMALLER                                               0, !4
         23      > JMPNZ                                                    ~16, ->9
    7    24    >   PRE_INC                                                  !3
         25    >   IS_SMALLER                                               !3, !2
         26      > JMPNZ                                                    ~18, ->6
   12    27    >   INIT_FCALL                                               'array_shift'
         28        SEND_REF                                                 !1
         29        DO_ICALL                                                 
   13    30      > RETURN                                                   !1
   14    31*     > RETURN                                                   null

End of function combs

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.94 ms | 1394 KiB | 22 Q