SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help needed on syntax

    I'm looking for the correct syntax to add (not replace) multiple items to a session array. The array is as follows;

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

    //the following part is a sample of the display code, (element [0] displays fine)

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


    echo $cart_items[0][style];
    echo $cart_items[1][style];

    Everything I have tried with a ++ argument comes up with an error. As you can see from the second part of the code I need to define element [1] but can't find any reference on how to add to the '[1]' element.

  2. #2
    SitePoint Zealot Dachande663's Avatar
    Join Date
    Feb 2005
    Location
    Birmingham, UK
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    echo $cart_items['style'];

    you don't have more than one style defined above.

  3. #3
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Not sure if that's what you're trying to do, but try:
    PHP Code:
    $cart_items[] = $_SESSION['cart']; 
    Saul


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •