3v4l.org

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

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.39 ms | 1000 KiB | 16 Q