3v4l.org

run code in 300+ PHP versions simultaneously
<?php $stores = [ 0 => "store3", 1 => "store", 2 => "store2" ]; $products = [ 0 => [ "store" => "store", "product" => "1" ], 1 => [ "store" => "store", "product" => "4" ], 2 => [ "store" => "store2", "product" => "2" ], 3 => [ "store" => "store2", "product" => "3" ], 4 => [ "store" => "store3", "product" => "7" ], 5 => [ "store" => "store3", "product" => "11" ] ]; $array = []; array_walk($products, function ($value, $key) use ($stores, &$array) { $array[$value['store']][] = $value['product']; }); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BfeMm
function name:  (null)
number of ops:  14
compiled vars:  !0 = $stores, !1 = $products, !2 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    7     1        ASSIGN                                                   !1, <array>
   33     2        ASSIGN                                                   !2, <array>
   34     3        INIT_FCALL                                               'array_walk'
          4        SEND_REF                                                 !1
          5        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
          6        BIND_LEXICAL                                             ~6, !0
          7        BIND_LEXICAL                                             ~6, !2
   36     8        SEND_VAL                                                 ~6
   34     9        DO_ICALL                                                 
   38    10        INIT_FCALL                                               'print_r'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
         13      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BfeMm
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $value, !1 = $key, !2 = $stores, !3 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
   35     4        FETCH_DIM_R                                      ~4      !0, 'store'
          5        FETCH_DIM_R                                      ~7      !0, 'product'
          6        FETCH_DIM_W                                      $5      !3, ~4
          7        ASSIGN_DIM                                               $5
          8        OP_DATA                                                  ~7
   36     9      > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.66 ms | 1006 KiB | 15 Q