3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['BLA' => 'bis 050'], ['BLA' => 'bis 060'], ['BLA' => 'bis 070'], ['BLA' => 'bis 080'], ['BLA' => 'bis 090'], ['BLA' => 'bis 100'], ['BLA' => 'bis 110'], ['BLA' => 'bis 120'], ['BLA' => 'gr 120'], ]; $map = [ ['BLA' => 'bis 050', 'Amount' => '832'], ['BLA' => 'bis 060', 'Amount' => '448'], ['BLA' => 'bis 090', 'Amount' => '1216'], ['BLA' => 'bis 100', 'Amount' => '1024'], ['BLA' => 'bis 110', 'Amount' => '8965'] ]; $lookup = array_column($map, 'Amount', 'BLA'); var_export( array_map( fn($row) => $row + ['Amount' => $lookup[$row['BLA']] ?? 0], $array ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cB4vF
function name:  (null)
number of ops:  18
compiled vars:  !0 = $array, !1 = $map, !2 = $lookup
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   15     1        ASSIGN                                                   !1, <array>
   23     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 'Amount'
          5        SEND_VAL                                                 'BLA'
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !2, $5
   24     8        INIT_FCALL                                               'var_export'
   25     9        INIT_FCALL                                               'array_map'
   26    10        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
         11        BIND_LEXICAL                                             ~7, !2
         12        SEND_VAL                                                 ~7
   27    13        SEND_VAR                                                 !0
   25    14        DO_ICALL                                         $8      
   27    15        SEND_VAR                                                 $8
   24    16        DO_ICALL                                                 
   29    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/cB4vF
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $row, !1 = $lookup
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        FETCH_DIM_R                                      ~2      !0, 'BLA'
          3        FETCH_DIM_IS                                     ~3      !1, ~2
          4        COALESCE                                         ~4      ~3
          5        QM_ASSIGN                                        ~4      0
          6        INIT_ARRAY                                       ~5      ~4, 'Amount'
          7        ADD                                              ~6      !0, ~5
          8      > RETURN                                                   ~6
          9*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.52 ms | 1005 KiB | 16 Q