Search⌘ K
AI Features

Removing Elements from Arrays

Explore how to remove elements from both indexed and associative arrays in PHP using the unset() function. Understand that unset deletes specified elements without reindexing the array, and how it can also destroy entire variables. This lesson prepares you for effective array management in PHP.

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 ...