need explaination
hello ,
im confused ., i need explanation , please help out , its in chapter 5 ,
function updateCart($productid,$fullproduct){
//pull in existing cart first!
$cart = $_SESSION['cart'];//$this->session->userdata('cart');
$productid = id_clean($productid);
$totalprice = 0;
if (count($fullproduct)){
if (isset($cart[$productid])){
$prevct = $cart[$productid]['count'];
$prevname = $cart[$productid]['name'];
$prevprice = $cart[$productid]['price'];
$cart[$productid] = array(
'name' => $prevname,
'price' => $prevprice,
'count' => $prevct + 1
);
}else{
$cart[$productid] = array(
'name' => $fullproduct['name'],
'price' => $this->format_currency($fullproduct['price']),
'count' => 1
);
}
i dont understand where 'cart' get value and what will be the output of this multidimensional array , please help me understand,
|