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(), $key = '', $value = ''){ $return = array(); $current = array_shift($source_arrays); foreach($current as $ck => $cv) { $ckey = $key.$ck; $cvalue = $value.$cv; if(!empty($source_arrays)) { $return += getAllCombinationsArray($source_arrays, $ckey.'_', $cvalue.' -> '); } else { $return[$ckey] = $cvalue; } } 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/jQ4vG
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>
   25     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 = 9, Position 2 = 30
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 30
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 27
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/jQ4vG
function name:  getAllCombinationsArray
number of ops:  33
compiled vars:  !0 = $source_arrays, !1 = $key, !2 = $value, !3 = $return, !4 = $current, !5 = $cv, !6 = $ck, !7 = $ckey, !8 = $cvalue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV_INIT                                        !0      <array>
          1        RECV_INIT                                        !1      ''
          2        RECV_INIT                                        !2      ''
    8     3        ASSIGN                                                   !3, <array>
   10     4        INIT_FCALL                                               'array_shift'
          5        SEND_REF                                                 !0
          6        DO_ICALL                                         $10     
          7        ASSIGN                                                   !4, $10
   12     8      > FE_RESET_R                                       $12     !4, ->30
          9    > > FE_FETCH_R                                       ~13     $12, !5, ->30
         10    >   ASSIGN                                                   !6, ~13
   13    11        CONCAT                                           ~15     !1, !6
         12        ASSIGN                                                   !7, ~15
   14    13        CONCAT                                           ~17     !2, !5
         14        ASSIGN                                                   !8, ~17
   15    15        ISSET_ISEMPTY_CV                                 ~19     !0
         16        BOOL_NOT                                         ~20     ~19
         17      > JMPZ                                                     ~20, ->27
   16    18    >   INIT_FCALL_BY_NAME                                       'getAllCombinationsArray'
         19        SEND_VAR_EX                                              !0
         20        CONCAT                                           ~21     !7, '_'
         21        SEND_VAL_EX                                              ~21
         22        CONCAT                                           ~22     !8, '+-%3E+'
         23        SEND_VAL_EX                                              ~22
         24        DO_FCALL                                      0  $23     
         25        ASSIGN_OP                                     1          !3, $23
         26      > JMP                                                      ->29
   18    27    >   ASSIGN_DIM                                               !3, !7
         28        OP_DATA                                                  !8
   12    29    > > JMP                                                      ->9
         30    >   FE_FREE                                                  $12
   22    31      > RETURN                                                   !3
   23    32*     > RETURN                                                   null

End of function getallcombinationsarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.58 ms | 1394 KiB | 18 Q