Is there a more efficient way of doing this? (Newbie)
Posted: Fri Sep 22, 2006 6:26 am
Was putting a 2D array into a session variable but found that it needed to be updated in an ordinary array before being assigned to the session.
The above code works fine.
Tried the following code but it doesn't work.
Code: Select all
if(isset($_SESSION['products'])) {
$products = $_SESSION['products'];
$products[] = array('id' => $id, 'quantity' => $quantity);
$_SESSION['products'] = $products;
}
else {
$products[] = array('id' => $id, 'quantity' => $quantity);
$_SESSION['products'] = $products;
}Tried the following code but it doesn't work.
Code: Select all
$_SESSION['products[]'] = array('id' => $id, 'quantity' => $quantity);