If you want to remove an element from an array, you can just use the PHP unset() method. The following example shows you how to remove an element from an array.
Example 1: How to remove a specific element from an associative array by key in PHP
<?php
$languages = array("p"=>"PHP", "j"=>"Java", "a"=>"Ada", "h"=>"HTML");
unset($languages["j"]);
print_r($languages);
?>
Output:
Array (
[p] => PHP
[a] => Ada
[h] => HTML
)Example 2: How to remove a specific element from an array by index in PHP
<?php
$nbrs = array(1, 2, 3, 4, 5);
unset($nbrs[1]);
print_r($nbrs);
?>
Output:Array (
[0] => 1
[2] => 3
[3] => 4
[4] => 5
)