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/5q6Xa
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 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
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
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 13
Branch analysis from position: 34
Branch analysis from position: 13
filename:       /in/5q6Xa
function name:  pc_permute
number of ops:  35
compiled vars:  !0 = $items, !1 = $perms, !2 = $combinations, !3 = $i, !4 = $newitems, !5 = $newperms, !6 = $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                                                     ~7, ->9
   12     4    >   INIT_FCALL                                               'array_push'
          5        SEND_REF                                                 !2
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
          8      > JMP                                                      ->34
   14     9    >   COUNT                                            ~9      !0
         10        SUB                                              ~10     ~9, 1
         11        ASSIGN                                                   !3, ~10
         12      > JMP                                                      ->32
   15    13    >   ASSIGN                                                   !4, !0
   16    14        ASSIGN                                                   !5, !1
   17    15        INIT_FCALL                                               'array_splice'
         16        SEND_REF                                                 !4
         17        SEND_VAR                                                 !3
         18        SEND_VAL                                                 1
         19        DO_ICALL                                         $14     
         20        FETCH_LIST_R                                     $15     $14, 0
         21        ASSIGN                                                   !6, $15
         22        FREE                                                     $14
   18    23        INIT_FCALL                                               'array_unshift'
         24        SEND_REF                                                 !5
         25        SEND_VAR                                                 !6
         26        DO_ICALL                                                 
   19    27        INIT_FCALL_BY_NAME                                       'pc_permute'
         28        SEND_VAR_EX                                              !4
         29        SEND_VAR_EX                                              !5
         30        DO_FCALL                                      0          
   14    31        PRE_DEC                                                  !3
         32    >   IS_SMALLER_OR_EQUAL                                      0, !3
         33      > JMPNZ                                                    ~20, ->13
   22    34    > > RETURN                                                   null

End of function pc_permute

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.83 ms | 1394 KiB | 22 Q