Category: PHP

Lop the array with foreach, and check if the key exists – if it doesn’t set the value to the quantity, if it does, add it to the existing quantity. The key represents the product. We check if it’s set or not to avoid having the code produce warnings (as you can see this demo […]