私はSESSION['cart']
ショッピングカートにを使用しています:
if(isset($_GET['product_id'])){
echo 'Good request!';
$product_id = $_GET['product_id'];
if(!isset($_SESSION['cart'])){
$_SESSION['cart'] = array();
echo 'There is no cart!';
}
$cart_row = array(
'product_id'=>$product_id
);
$_SESSION['cart'][] = $cart_row;
}
以下を使用してアイテムを追加する場合:
addToCart.php?product_id=12345
最初のアイテムは追加されませんが、後続のアイテムは追加されます。
最初のアイテムが配列に含まれていない理由がわかりませんか?