Removing Elements from Arrays

This lesson discusses an important array operation, i.e., removing elements from an array.

PHP built-in function unset() is used to remove an element from an array.

Removing Elements from Indexed Arrays #

Specifying an array element as an input parameter for unset() will remove that element from an indexed array. Below is the code for removing an element at index 1 in the array $fruit:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy