jeudi 25 juin 2020

How do I add a remove function based on my code? (PHP and HTML)

Im trying out some exercise Ive found online, and I reach dead end. I know to use unset() to remove a specific array, however I dont understand how it actually works. Here is my code:

<?php session_start();
if (empty($_SESSION['cart'])) {  //check if array is empty
    $_SESSION['cart']= array(); 
    }

    array_push($_SESSION['cart'],$_POST['apples']);  //store array 
    array_push($_SESSION['cart'],$_POST['banana']); ?>

And the rest of the code is in html. Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire