<?php
$ingredients = [
['name' => 'TV','amount' => 3],
['name' => 'LAPTOP', 'amount' => 2],
['name' => 'HAREM', 'amount' => 2],
['name' => 'OIL', 'amount' => 1],
['name' => 'Windows', 'amount' => 1],
['name' => 'Something', 'amount' => 1]
];
$prices = [
'TV' => 20,
'LAPTOP' => 20,
'HAREM' => 25,
'OIL' => 20,
'Windows' => 25,
'Something' => 35
];
$name = array_column($ingredients,"name");
Foreach($prices as $item => $price){
$find = array_search($item, $name);
If($find !== false) $res[$item] = $price * $ingredients[$find]['amount'];
}
Var_dump($res);
preferences:
24.02 ms | 406 KiB | 5 Q