Forum Moderators: coopster

Message Too Old, No Replies

problems echoing from array

         

triangulum

10:43 am on Jun 17, 2006 (gmt 0)

10+ Year Member



this code doesn't display can anyone tell me why?

$_SESSION['cart'] = array(
style => $style,
width => $width,
height => $height,
price => $price,
position => $position,
open => $open,
control => $control,
cord => $cord,
quantity => $quantity
);

$cart_items = array ($_SESSION['cart']);


echo $cart_items[1][style];

ArthurDent

10:45 am on Jun 17, 2006 (gmt 0)

10+ Year Member



$cart_items[1] isn't defined. drop the [1] and it should work. if not, echo the array with print_r($cart_items). then you see, how it is defined internally.

triangulum

11:12 am on Jun 17, 2006 (gmt 0)

10+ Year Member



Thanks Arthur,

My problem was, I assumed that the code added new items to the cart and it actually doesn't. So $cart_items[1] is of course always empty.

Back to scratching head.