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($root, $child_1, $child_2){ $return = array(); foreach($root as $fk => $fv){ foreach($child_1 as $ck => $cv){ $cid = $fk.'_'.$ck; $cname = $fv.' -> '.$cv; foreach($child_2 as $ck2 => $cv2){ $id = $cid.'_'.$ck2; $name = $cname.' -> '.$cv2; $return[$id] = $name; } } } return $return; } print_r(getAllCombinationsArray($root, $child_1, $child_2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aZgsf
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%2FaZgsf%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%2FaZgsf%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%2FaZgsf%3A5%242'
         22        SEND_VAL                                                 ~11
         23        INIT_FCALL                                               'range'
         24        SEND_VAL                                                 1
         25        SEND_VAL                                                 30
         26        DO_ICALL                                         $12     
         27        SEND_VAR                                                 $12
         28        DO_ICALL                                         $13     
         29        ASSIGN                                                   !2, $13
   25    30        INIT_FCALL                                               'print_r'
         31        INIT_FCALL                                               'getallcombinationsarray'
         32        SEND_VAR                                                 !0
         33        SEND_VAR                                                 !1
         34        SEND_VAR                                                 !2
         35        DO_FCALL                                      0  $15     
         36        SEND_VAR                                                 $15
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FaZgsf%3A3%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aZgsf
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%2FaZgsf%3A3%240

Function %00%7Bclosure%7D%2Fin%2FaZgsf%3A4%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aZgsf
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%2FaZgsf%3A4%241

Function %00%7Bclosure%7D%2Fin%2FaZgsf%3A5%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aZgsf
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%2FaZgsf%3A5%242

Function getallcombinationsarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 32
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 32
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 30
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 30
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 28
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 28
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 28
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 30
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/aZgsf
function name:  getAllCombinationsArray
number of ops:  35
compiled vars:  !0 = $root, !1 = $child_1, !2 = $child_2, !3 = $return, !4 = $fv, !5 = $fk, !6 = $cv, !7 = $ck, !8 = $cid, !9 = $cname, !10 = $cv2, !11 = $ck2, !12 = $id, !13 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    8     3        ASSIGN                                                   !3, <array>
   11     4      > FE_RESET_R                                       $15     !0, ->32
          5    > > FE_FETCH_R                                       ~16     $15, !4, ->32
          6    >   ASSIGN                                                   !5, ~16
   12     7      > FE_RESET_R                                       $18     !1, ->30
          8    > > FE_FETCH_R                                       ~19     $18, !6, ->30
          9    >   ASSIGN                                                   !7, ~19
   13    10        CONCAT                                           ~21     !5, '_'
         11        CONCAT                                           ~22     ~21, !7
         12        ASSIGN                                                   !8, ~22
   14    13        CONCAT                                           ~24     !4, '+-%3E+'
         14        CONCAT                                           ~25     ~24, !6
         15        ASSIGN                                                   !9, ~25
   15    16      > FE_RESET_R                                       $27     !2, ->28
         17    > > FE_FETCH_R                                       ~28     $27, !10, ->28
         18    >   ASSIGN                                                   !11, ~28
   16    19        CONCAT                                           ~30     !8, '_'
         20        CONCAT                                           ~31     ~30, !11
         21        ASSIGN                                                   !12, ~31
   17    22        CONCAT                                           ~33     !9, '+-%3E+'
         23        CONCAT                                           ~34     ~33, !10
         24        ASSIGN                                                   !13, ~34
   18    25        ASSIGN_DIM                                               !3, !12
         26        OP_DATA                                                  !13
   15    27      > JMP                                                      ->17
         28    >   FE_FREE                                                  $27
   12    29      > JMP                                                      ->8
         30    >   FE_FREE                                                  $18
   11    31      > JMP                                                      ->5
         32    >   FE_FREE                                                  $15
   22    33      > RETURN                                                   !3
   23    34*     > RETURN                                                   null

End of function getallcombinationsarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.51 ms | 1407 KiB | 20 Q