Delete an array element based on key

    By: Manu
    3 years ago

    It is simple use php function 'unset'.

    $array = [
                  0 => "apple", 
                  1 => "banana", 
                  2 => "chocolate", 
                  3 => "chocolate"
             ];
    
    unset($array[1]); //removes banana from array
    

    Hope it helps