Hi
I have an array which looks a little like this, the first number in each array is a quantity
$cars = array (
array(1,"BMW",15,13),
array(8,"BMW",15,13),
array(3,"Saab",5,2),
array(4,"BMW",11,7),
array(5,"Land Rover",17,15),
array(6,"Saab",5,2)
);
what I want to do is combine any array which matches another, but ignoring the quanitity value (first one).
Then creating the array again and adding up the quanitity values and re-inserting them at the start.
Therefore the end result would look like
$cars = array (
array(9,"BMW",15,13),
array(9,"Saab",5,2),
array(4,"BMW",11,7),
array(5,"Land Rover",17,15),
);
Has anyone got any ideas on how I might do this?
Thanks