3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ [ 'count_employee' => 2, 'name' => 'Harry' ], [ 'count_employee' => 61, 'name' => 'Jack' ], [ 'count_employee' => 11, 'name' => 'John' ], [ 'count_warehouse' => 1, 'name' => 'Harry' ], [ 'count_warehouse' => 77, 'name' => 'John' ], [ 'count_warehouse' => 45, 'name' => 'Jack' ] ]; $res=[]; array_walk($arr, function($v,$k) use (&$res){ if(array_key_exists($v['name'], $res)) $res[$v['name']]['count_warehouse'] = $v['count_warehouse']; else $res[$v['name']] = $v; }); print_r($res);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iM6G2
function name:  (null)
number of ops:  12
compiled vars:  !0 = $arr, !1 = $res
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   29     1        ASSIGN                                                       !1, <array>
   30     2        INIT_FCALL                                                   'array_walk'
          3        SEND_REF                                                     !0
          4        DECLARE_LAMBDA_FUNCTION                              ~4      [0]
          5        BIND_LEXICAL                                                 ~4, !1
   35     6        SEND_VAL                                                     ~4
   30     7        DO_ICALL                                                     
   36     8        INIT_FCALL                                                   'print_r'
          9        SEND_VAR                                                     !1
         10        DO_ICALL                                                     
         11      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iM6G2
function name:  {closure:/in/iM6G2:30}
number of ops:  16
compiled vars:  !0 = $v, !1 = $k, !2 = $res
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   30     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
   31     3        FETCH_DIM_R                                          ~3      !0, 'name'
          4        ARRAY_KEY_EXISTS                                             ~3, !2
          5      > JMPZ                                                         ~4, ->12
   32     6    >   FETCH_DIM_R                                          ~5      !0, 'name'
          7        FETCH_DIM_R                                          ~8      !0, 'count_warehouse'
          8        FETCH_DIM_W                                          $6      !2, ~5
          9        ASSIGN_DIM                                                   $6, 'count_warehouse'
         10        OP_DATA                                                      ~8
   31    11      > JMP                                                          ->15
   34    12    >   FETCH_DIM_R                                          ~9      !0, 'name'
         13        ASSIGN_DIM                                                   !2, ~9
         14        OP_DATA                                                      !0
   35    15    > > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.23 ms | 2130 KiB | 15 Q