3v4l.org

run code in 300+ PHP versions simultaneously
<?php $root = array_map(function($v) { return 'cat'.$v; }, range(1,10)); //array( 1=>'cat1', 2=>'cat2', 3=>'cat3' ); $child_1 = array_map(function($v) { return 'sub_cat'.$v; },range(1,16)); //array( 1=>'sub_cat1', 2=>'sub_cat2', 3=>'sub_cat3' ); $child_2 = array_map(function($v) { return 'sub_sub_cat'.$v; },range(1.30)); //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_push($kdi, $ck); $vdi = $vd; array_push($vdi, $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/fMPqR
function name:  (null)
number of ops:  39
compiled vars:  !0 = $root, !1 = $child_1, !2 = $child_2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'array_map'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfMPqR%3A3%240'
          2        SEND_VAL                                                 ~3
          3        INIT_FCALL                                               'range'
          4        SEND_VAL                                                 1
          5        SEND_VAL                                                 10
          6        DO_ICALL                                         $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                         $5      
          9        ASSIGN                                                   !0, $5
    4    10        INIT_FCALL                                               'array_map'
         11        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfMPqR%3A4%241'
         12        SEND_VAL                                                 ~7
         13        INIT_FCALL                                               'range'
         14        SEND_VAL                                                 1
         15        SEND_VAL                                                 16
         16        DO_ICALL                                         $8      
         17        SEND_VAR                                                 $8
         18        DO_ICALL                                         $9      
         19        ASSIGN                                                   !1, $9
    5    20        INIT_FCALL                                               'array_map'
         21        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfMPqR%3A5%242'
         22        SEND_VAL                                                 ~11
         23        INIT_FCALL                                               'range'
         24        SEND_VAL                                                 1.3
         25        DO_ICALL                                         $12     
         26        SEND_VAR                                                 $12
         27        DO_ICALL                                         $13     
         28        ASSIGN                                                   !2, $13
   25    29        INIT_FCALL                                               'print_r'
         30        INIT_FCALL                                               'getallcombinationsarray'
         31        INIT_ARRAY                                       ~15     !0
         32        ADD_ARRAY_ELEMENT                                ~15     !1
         33        ADD_ARRAY_ELEMENT                                ~15     !2
         34        SEND_VAL                                                 ~15
         35        DO_FCALL                                      0  $16     
         36        SEND_VAR                                                 $16
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FfMPqR%3A3%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fMPqR
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        CONCAT                                           ~1      'cat', !0
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FfMPqR%3A3%240

Function %00%7Bclosure%7D%2Fin%2FfMPqR%3A4%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fMPqR
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        CONCAT                                           ~1      'sub_cat', !0
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FfMPqR%3A4%241

Function %00%7Bclosure%7D%2Fin%2FfMPqR%3A5%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fMPqR
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        CONCAT                                           ~1      'sub_sub_cat', !0
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FfMPqR%3A5%242

Function getallcombinationsarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 41
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 41
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 30
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/fMPqR
function name:  getAllCombinationsArray
number of ops:  44
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, ->41
          8    > > FE_FETCH_R                                       ~11     $10, !4, ->41
          9    >   ASSIGN                                                   !5, ~11
   11    10        ASSIGN                                                   !6, !1
   12    11        INIT_FCALL                                               'array_push'
         12        SEND_REF                                                 !6
         13        SEND_VAR                                                 !5
         14        DO_ICALL                                                 
   13    15        ASSIGN                                                   !7, !2
   14    16        INIT_FCALL                                               'array_push'
         17        SEND_REF                                                 !7
         18        SEND_VAR                                                 !4
         19        DO_ICALL                                                 
   15    20        ISSET_ISEMPTY_CV                                 ~17     !0
         21        BOOL_NOT                                         ~18     ~17
         22      > JMPZ                                                     ~18, ->30
   16    23    >   INIT_FCALL_BY_NAME                                       'getAllCombinationsArray'
         24        SEND_VAR_EX                                              !0
         25        SEND_VAR_EX                                              !6
         26        SEND_VAR_EX                                              !7
         27        DO_FCALL                                      0  $19     
         28        ASSIGN_OP                                     1          !3, $19
         29      > JMP                                                      ->40
   18    30    >   INIT_FCALL                                               'implode'
         31        SEND_VAL                                                 '_'
         32        SEND_VAR                                                 !6
         33        DO_ICALL                                         $21     
         34        INIT_FCALL                                               'implode'
         35        SEND_VAL                                                 '+-%3E+'
         36        SEND_VAR                                                 !7
         37        DO_ICALL                                         $23     
         38        ASSIGN_DIM                                               !3, $21
         39        OP_DATA                                                  $23
   10    40    > > JMP                                                      ->8
         41    >   FE_FREE                                                  $10
   22    42      > RETURN                                                   !3
   23    43*     > RETURN                                                   null

End of function getallcombinationsarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.49 ms | 1398 KiB | 26 Q