I have this problem : i'm working on a small e-shop and I have about 60 products in the database . all the products have a code , like : 4444, 5334, 3244 and so on . The problem is that there are also product packs and they are made out of several products .
I have to do th开发者_StackOverflow社区is : everytime there is an update to the CART there must be a script checking if the products in CART can make a PRODUCT PACK and replace all the products from the CART with that product pack .
What do you think would be the best way to do this check / change ?
Assuming $packs
is an array of arrays of items, and $cart
is an array of items:
foreach($packs as $pack) {
$diff = array_diff($pack, $cart);
if (empty($diff)) {
// $cart contains this pack
}
}
精彩评论