3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = [10, 2, 5, 10, 0]; $b = [1, 20, 11, 8, 3]; var_export( array_reduce( array_keys($b), fn ($result, $k) => array_replace($result, [$k => ($result[$k] ?? 0) + $b[$k]]), $a ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8Efoc
function name:  (null)
number of ops:  16
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'var_export'
    7     3        INIT_FCALL                                               'array_reduce'
    8     4        INIT_FCALL                                               'array_keys'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $4      
          7        SEND_VAR                                                 $4
    9     8        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          9        BIND_LEXICAL                                             ~5, !1
         10        SEND_VAL                                                 ~5
   10    11        SEND_VAR                                                 !0
    7    12        DO_ICALL                                         $6      
   10    13        SEND_VAR                                                 $6
    6    14        DO_ICALL                                                 
   12    15      > 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/8Efoc
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $result, !1 = $k, !2 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        INIT_FCALL                                               'array_replace'
          4        SEND_VAR                                                 !0
          5        FETCH_DIM_IS                                     ~3      !0, !1
          6        COALESCE                                         ~4      ~3
          7        QM_ASSIGN                                        ~4      0
          8        FETCH_DIM_R                                      ~5      !2, !1
          9        ADD                                              ~6      ~4, ~5
         10        INIT_ARRAY                                       ~7      ~6, !1
         11        SEND_VAL                                                 ~7
         12        DO_ICALL                                         $8      
         13      > RETURN                                                   $8
         14*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.57 ms | 1006 KiB | 17 Q