3v4l.org

run code in 300+ PHP versions simultaneously
<?php $root = array( 1=>'cat1', 2=>'cat2', 3=>'cat3' ); $child_1 = array( 1=>'sub_cat1', 2=>'sub_cat2', 3=>'sub_cat3' ); $child_2 = array( 1=>'sub_sub_cat1', 2=>'sub_sub_cat2', 3=>'sub_sub_cat3' ); function getAllCombinationsArray($source_arrays = array(), $kd = array(), $vd = array()){ $return = array(); foreach(array_shift($source_arrays) as $ck => $cv) { $kdi = $kd + (array)$ck; $vdi = $vd + (array)$cv; if(!empty($source_arrays)) { $return += getAllCombinationsArray($source_arrays, $kdi, $vdi); } else { $return[implode('_', $kdi)] = implode(' -> ', $vdi); } } return $return; } print_r(getAllCombinationsArray(array($root, $child_1, $child_2)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7RbtB
function name:  (null)
number of ops:  13
compiled vars:  !0 = $root, !1 = $child_1, !2 = $child_2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
   23     3        INIT_FCALL                                               'print_r'
          4        INIT_FCALL                                               'getallcombinationsarray'
          5        INIT_ARRAY                                       ~6      !0
          6        ADD_ARRAY_ELEMENT                                ~6      !1
          7        ADD_ARRAY_ELEMENT                                ~6      !2
          8        SEND_VAL                                                 ~6
          9        DO_FCALL                                      0  $7      
         10        SEND_VAR                                                 $7
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function getallcombinationsarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 37
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 37
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/7RbtB
function name:  getAllCombinationsArray
number of ops:  40
compiled vars:  !0 = $source_arrays, !1 = $kd, !2 = $vd, !3 = $return, !4 = $cv, !5 = $ck, !6 = $kdi, !7 = $vdi
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV_INIT                                        !0      <array>
          1        RECV_INIT                                        !1      <array>
          2        RECV_INIT                                        !2      <array>
    8     3        ASSIGN                                                   !3, <array>
   10     4        INIT_FCALL                                               'array_shift'
          5        SEND_REF                                                 !0
          6        DO_ICALL                                         $9      
          7      > FE_RESET_R                                       $10     $9, ->37
          8    > > FE_FETCH_R                                       ~11     $10, !4, ->37
          9    >   ASSIGN                                                   !5, ~11
   11    10        CAST                                          7  ~13     !5
         11        ADD                                              ~14     !1, ~13
         12        ASSIGN                                                   !6, ~14
   12    13        CAST                                          7  ~16     !4
         14        ADD                                              ~17     !2, ~16
         15        ASSIGN                                                   !7, ~17
   13    16        ISSET_ISEMPTY_CV                                 ~19     !0
         17        BOOL_NOT                                         ~20     ~19
         18      > JMPZ                                                     ~20, ->26
   14    19    >   INIT_FCALL_BY_NAME                                       'getAllCombinationsArray'
         20        SEND_VAR_EX                                              !0
         21        SEND_VAR_EX                                              !6
         22        SEND_VAR_EX                                              !7
         23        DO_FCALL                                      0  $21     
         24        ASSIGN_OP                                     1          !3, $21
         25      > JMP                                                      ->36
   16    26    >   INIT_FCALL                                               'implode'
         27        SEND_VAL                                                 '_'
         28        SEND_VAR                                                 !6
         29        DO_ICALL                                         $23     
         30        INIT_FCALL                                               'implode'
         31        SEND_VAL                                                 '+-%3E+'
         32        SEND_VAR                                                 !7
         33        DO_ICALL                                         $25     
         34        ASSIGN_DIM                                               !3, $23
         35        OP_DATA                                                  $25
   10    36    > > JMP                                                      ->8
         37    >   FE_FREE                                                  $10
   20    38      > RETURN                                                   !3
   21    39*     > RETURN                                                   null

End of function getallcombinationsarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.95 ms | 1403 KiB | 20 Q