multi dimensional array producing a parse error
| From: | Sheila Myers | Date: | Tue, 16 Oct 2001 18:20:53 +0000 |
| Subject: | multi dimensional array producing a parse error | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-71245@lists.php.net to get a copy of this message | ||
I'm struggling with using a multidimensional array in my shopping cart
class. Can anyone tell me why this code is generating a parse error at
the indicated line?
Thanks,
Sheila
Class Cart
{
var $items = array("productid"=>'',
"details"=>array(
"price"=>'',
"quantity"=>'',
"shipping"=>'',
"tax"=>'',
"desc"=>'',
"note"=>'')
);
var $product_total;
var $shipping_total;
var $tax_total;
var $cart_id;
function
add($sell_price,$qty,$shipping,$tax,$productid,$short_desc,$note)
{
/* add an item to the shopping cart and update the total price */
if (isset($this->items[$productid])) //if it is already in the cart,
don't add a new occurence, just update the total quantity
{
$this->items[$productid]["quantity"] += $qty;
}
else
{
$this->items["productid"]=>$productid; <<<==================this is the
line reporting the parse error
$this->items[$productid]["price"]=>$sell_price;
$this->items[$productid]["quantity"]=>$qty;
$this->items[$productid]["shipping"]=>$shipping;
$this->items[$productid]["tax"]=>$tax;
$this->items[$productid]["desc"]=>$short_desc;
$this->items[$productid]["note"]=>$note;
$this->product_total = $this->product_total += $sell_price;
$this->shipping_total = $this->shipping_total += $shipping;
}
var_dump $this->items; //debugging
} //end add