3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array_one = [ [ 'product_id' => 1, 'product_stock' => '1.2', 'stock_date' => '2022-02-15' ], [ 'product_id' => 2, 'product_stock' => '5', 'stock_date' => '2022-02-15' ], ]; $array_two = [ [ 'product_id' => 1, 'product_slug' => 'product_one', 'product_description' => 'this is the product one' ], [ 'product_id' => 2, 'product_slug' => 'product_two', 'product_description' => 'this is the product two' ], [ 'product_id' => 3, 'product_slug' => 'product_three', 'product_description' => 'this is the product three' ], ]; $lookup = array_column($array_two, null, 'product_id'); var_export( array_map( fn($row) => $row + $lookup[$row['product_id']], $array_one ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jfWBP
function name:  (null)
number of ops:  18
compiled vars:  !0 = $array_one, !1 = $array_two, !2 = $lookup
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   15     1        ASSIGN                                                   !1, <array>
   33     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 null
          5        SEND_VAL                                                 'product_id'
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !2, $5
   34     8        INIT_FCALL                                               'var_export'
   35     9        INIT_FCALL                                               'array_map'
   36    10        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
         11        BIND_LEXICAL                                             ~7, !2
         12        SEND_VAL                                                 ~7
   37    13        SEND_VAR                                                 !0
   35    14        DO_ICALL                                         $8      
   37    15        SEND_VAR                                                 $8
   34    16        DO_ICALL                                                 
   39    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/jfWBP
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $row, !1 = $lookup
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        FETCH_DIM_R                                      ~2      !0, 'product_id'
          3        FETCH_DIM_R                                      ~3      !1, ~2
          4        ADD                                              ~4      !0, ~3
          5      > RETURN                                                   ~4
          6*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.1 ms | 1002 KiB | 16 Q