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 ) );
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
array ( 0 => array ( 'BLA' => 'bis 050', 'Amount' => '832', ), 1 => array ( 'BLA' => 'bis 060', 'Amount' => '448', ), 2 => array ( 'BLA' => 'bis 070', 'Amount' => 0, ), 3 => array ( 'BLA' => 'bis 080', 'Amount' => 0, ), 4 => array ( 'BLA' => 'bis 090', 'Amount' => '1216', ), 5 => array ( 'BLA' => 'bis 100', 'Amount' => '1024', ), 6 => array ( 'BLA' => 'bis 110', 'Amount' => '8965', ), 7 => array ( 'BLA' => 'bis 120', 'Amount' => 0, ), 8 => array ( 'BLA' => 'gr 120', 'Amount' => 0, ), )

preferences:
69.27 ms | 408 KiB | 5 Q