3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "800"; function getCombinations($array) { //initalize array $results = [[]]; //get all combinations foreach ($array as $k => $element) { foreach ($results as $combination) $results[] = $combination + [$k => $element]; } //return filtered array return array_values(array_filter($results)); } $arr = getCombinations(str_split($str, "")); foreach($arr as $v) echo implode(" ", $v) . "<br />";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 18
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/h0TBV
function name:  (null)
number of ops:  20
compiled vars:  !0 = $str, !1 = $arr, !2 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '800'
   23     1        INIT_FCALL                                               'getcombinations'
          2        INIT_FCALL                                               'str_split'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 ''
          5        DO_ICALL                                         $4      
          6        SEND_VAR                                                 $4
          7        DO_FCALL                                      0  $5      
          8        ASSIGN                                                   !1, $5
   25     9      > FE_RESET_R                                       $7      !1, ->18
         10    > > FE_FETCH_R                                               $7, !2, ->18
   26    11    >   INIT_FCALL                                               'implode'
         12        SEND_VAL                                                 '+'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $8      
         15        CONCAT                                           ~9      $8, '%3Cbr+%2F%3E'
         16        ECHO                                                     ~9
   25    17      > JMP                                                      ->10
         18    >   FE_FREE                                                  $7
   26    19      > RETURN                                                   1

Function getcombinations:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/h0TBV
function name:  getCombinations
number of ops:  23
compiled vars:  !0 = $array, !1 = $results, !2 = $element, !3 = $k, !4 = $combination
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    9     1        ASSIGN                                                   !1, <array>
   12     2      > FE_RESET_R                                       $6      !0, ->14
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->14
          4    >   ASSIGN                                                   !3, ~7
   13     5      > FE_RESET_R                                       $9      !1, ->12
          6    > > FE_FETCH_R                                               $9, !4, ->12
   14     7    >   INIT_ARRAY                                       ~11     !2, !3
          8        ADD                                              ~12     !4, ~11
          9        ASSIGN_DIM                                               !1
         10        OP_DATA                                                  ~12
   13    11      > JMP                                                      ->6
         12    >   FE_FREE                                                  $9
   12    13      > JMP                                                      ->3
         14    >   FE_FREE                                                  $6
   18    15        INIT_FCALL                                               'array_values'
         16        INIT_FCALL                                               'array_filter'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $13     
         19        SEND_VAR                                                 $13
         20        DO_ICALL                                         $14     
         21      > RETURN                                                   $14
   20    22*     > RETURN                                                   null

End of function getcombinations

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.11 ms | 1403 KiB | 22 Q