append associative array to session, losing assoc values...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
visitor-Q
Forum Commoner
Posts: 72
Joined: Mon Feb 05, 2007 1:40 am

append associative array to session, losing assoc values...

Post by visitor-Q »

why is it that when i add an item to my shopping cart, it loses the associative values???

Code: Select all

if(isset($_POST)){
        $_SESSION['shopping_cart'][] = $_POST;
}
here are the values of the arrays;

Code: Select all

POST ARRAY:
Array
(
    [id] => 12
    [name] => Sandwich
    [price] => 6.5
    [quantity] => 1
    [ingredients] => Array
        (
            [0] => mayonnaise
            [1] => lettuce
            [2] => tomatoes
            [3] => cheese
        )

)


SESSION ARRAY:
Array
(
    [session_id] => 299c29cfa3ed5119f8b383455de1117d
    [shopping_cart] => Array
        (
            [0] => Array
                (
                    [0] => 1
                    [1] => 6.5
                    [2] => 12
                    [3] => Sandwich
                    [4] => Array
                        (
                           [0] => mayonnaise
                           [1] => lettuce
                           [2] => tomatoes
                           [3] => cheese
                        )

                )

        )

)
visitor-Q
Forum Commoner
Posts: 72
Joined: Mon Feb 05, 2007 1:40 am

Post by visitor-Q »

i don't know what happened, or what i changed... but for some reason... it's not losing the associative values anymore... wtf...
Post Reply