PHP Program to delete an array element array_splice

bookmark

<?php

    $array = array(0 => "apple", 1 => "banana", 2 => "carrot");

    //Splice the array beginning from 1 index,
    //ie second element and delete 1 element.
    array_splice($array, 1, 1);

    //Print the array
    echo $array; // Output: (0 => "apple", 1 => "carrot")

?>

Output:

(0 => "apple", 1 => "carrot")