Hi,
Can someone clear this up for me.
I want to use an array in a session variable so I do:
$_SESSION['cart[]']; to initialize. Or is it better to do:
$_SESSION['cart'] = array();
I receive a value (new) from another page so I do:
if($GET['new']
$new = $GET['new'];
I want to now check and see if this value exists in my variable $cart so I try:
if(array_key_exists("$new", $cart))
$cart("$new")++;
//(not sure if this is correct but if the key $new already exists in the array, I want to add 1 to the value matching the key $new)
else // it does not exist in the array so
$cart("$new") = 1;
// assign a value of 1 to the key $new
Does this look right? Because this is a session variable, do I have to use $_SESSION somehow with $cart in order to manipulate this array or is it sufficient once the variable has been registered to use only $cart? NOTE: I have register_globals turned off.
Thanks in advance.
Dave