i've looked and looked, and can't find out how to change a session variable and store it back into the array. my code does what i want so far, and adds 1 to the variable, but i don't know how to save it back into the array. my code is as follows.
if(isset($_GET['action']) && $_GET['action'] == 'addp')
{
echo "trying to add 1 item to serial ".$_GET['id']."<br>";
$product_code = filter_var($_GET['id'], FILTER_SANITIZE_STRING);
if(isset($_SESSION['products']))
{
$number = 0;
foreach($_SESSION['products'] as $cart_itm)
{
if($cart_itm['code'] == $product_code)
{
$a = array($_SESSION['products']);
foreach($_SESSION['products'] as $a){
foreach($a as $b){
while(list($key, $val) = each($a)){
if($key == 'qty'){
$val = $val + 1;
echo $val;
}
}
}
}
}
else
{
echo"Item Code Did not Match";
}
$number++;
}
}
else
{
echo"Session['Products'] Not Set";
}
}
else
{
echo"Action is set to ".$_GET['action'];
}
Any help, even if its pointing me at a post I failed to look at would help.
Also, any pointers on code style would be appreciated.
print_rof the$_SESSIONarray and what you want it changed to and the criteria to change it would help.$_SESSION['products']? Isn't$athe same as$cart_itm?$_SESSION['products']and show us the structure of it