I have an array called $products_list filled with data, with the following structure:
$products_list[] = [
'manufacturer' => $manufacturer_name,
'mpn' => $mpn,
'description' => $description,
'quantity' => $quantity,
'condition' => $condition,
'price' => $price
];
I am trying to remove any duplicate values from array if they have the same description && condition and to merge the quantity from duplicates.
I tried to to set the data into a temporary array for being able to compare the two arrays into a foreach statement. something like this:
foreach($products_list as $key => $row) {
if($test_data['description'] == $row['description'] && $test_data['isbn'] == $isbn)
{
echo $row['description'];
echo $row['quantity']+$temp_quantity;
}
$test_data = [
'description' => $row['description'],
'isbn' => $row['isbn'],
'quantity' =>
];
}