Can you explain the difference between array_splice and other array manipulation functions in PHP?

Array_splice in PHP is used to remove a portion of an array and replace it with new elements. It differs from other array manipulation functions like array_push, array_pop, array_shift, and array_unshift, which mainly add or remove elements from the beginning or end of an array. Array_splice allows for more flexibility in modifying arrays by specifying the start index, length of elements to remove, and new elements to insert.

// Example of using array_splice to remove elements from an array
$fruits = array("apple", "banana", "cherry", "date");
array_splice($fruits, 1, 2); // Removes "banana" and "cherry"
print_r($fruits); // Outputs: Array ( [0] => apple [1] => date )