PHP Delete Array Items

Remove Array Item

To remove an existing item from an array, you can use the array_splice() function.

With the array_splice() function you specify the index (where to start) and how many items you want to delete.

Example

Remove the second item:

$cars = array("Volvo", "BMW", "Toyota");
array_splice($cars, 1, 1);

After the deletion, the array gets reindexed automatically, starting at index 0. Continue reading PHP Delete Array Items