Posted by Jussist on 01/02/07 09:17
Now this is a perfect place to go OO. Instead of having those weird
associative arrays, use objects.
<?php
class Prodcuct {
$name;
$price;
}
?>
<?php
class CartItem {
$product;
$quantity;
}
?>
<?php
$newProductToCart = new CartItem();
$newProductToCart->setProduct($myProduct);
$newProductToCart->setAmount(5);
$MyCart[] = $newProductToCart;
?>
<?php
for($i=0;$i<count($MyCart);$i++) {
echo "Product:" . $MyCart[$i]->getProduct()->getName() . " - " .
$MyCart[$i]->getAmount();
}
?>
That's the general idea anyway.
Navigation:
[Reply to this message]
|