3v4l.org

run code in 300+ PHP versions simultaneously
<?php $products = [1, 2, 3, 4, 5]; $vendors = ["Amazon", "Newegg", "Frys"]; $combinations = array(''); function pc_permute($items, $perms = array()) { if (empty($items)) { echo join(' ', $perms) . "</br>"; //return $perms; //array_push($combinations, $perms); } else { for ($i = count($items) - 1; $i >= 0; --$i) { $newitems = $items; $newperms = $perms; list($foo) = array_splice($newitems, $i, 1); array_unshift($newperms, $foo); pc_permute($newitems, $newperms); } } } pc_permute($products); var_dump($combinations);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OCL60
function name:  (null)
number of ops:  10
compiled vars:  !0 = $products, !1 = $vendors, !2 = $combinations
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, <array>
   24     3        INIT_FCALL                                               'pc_permute'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0          
   25     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function pc_permute:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 15
Branch analysis from position: 36
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 15
Branch analysis from position: 36
Branch analysis from position: 15
filename:       /in/OCL60
function name:  pc_permute
number of ops:  37
compiled vars:  !0 = $items, !1 = $perms, !2 = $i, !3 = $newitems, !4 = $newperms, !5 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
    9     2        ISSET_ISEMPTY_CV                                         !0
          3      > JMPZ                                                     ~6, ->11
   10     4    >   INIT_FCALL                                               'join'
          5        SEND_VAL                                                 '+'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $7      
          8        CONCAT                                           ~8      $7, '%3C%2Fbr%3E'
          9        ECHO                                                     ~8
         10      > JMP                                                      ->36
   14    11    >   COUNT                                            ~9      !0
         12        SUB                                              ~10     ~9, 1
         13        ASSIGN                                                   !2, ~10
         14      > JMP                                                      ->34
   15    15    >   ASSIGN                                                   !3, !0
   16    16        ASSIGN                                                   !4, !1
   17    17        INIT_FCALL                                               'array_splice'
         18        SEND_REF                                                 !3
         19        SEND_VAR                                                 !2
         20        SEND_VAL                                                 1
         21        DO_ICALL                                         $14     
         22        FETCH_LIST_R                                     $15     $14, 0
         23        ASSIGN                                                   !5, $15
         24        FREE                                                     $14
   18    25        INIT_FCALL                                               'array_unshift'
         26        SEND_REF                                                 !4
         27        SEND_VAR                                                 !5
         28        DO_ICALL                                                 
   19    29        INIT_FCALL_BY_NAME                                       'pc_permute'
         30        SEND_VAR_EX                                              !3
         31        SEND_VAR_EX                                              !4
         32        DO_FCALL                                      0          
   14    33        PRE_DEC                                                  !2
         34    >   IS_SMALLER_OR_EQUAL                                      0, !2
         35      > JMPNZ                                                    ~20, ->15
   22    36    > > RETURN                                                   null

End of function pc_permute

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.53 ms | 1402 KiB | 22 Q