array remove element if found php code example
Example 1: php remove item array
$items = ['banana', 'apple'];
unset($items[0]);
var_dump($items); // ['apple']
Example 2: php array remove value if exists
<?php
$myArray = array ('Alan', 'Peter', 'Linus', 'Larry');
$pos = array_search('Linus', $myArray);
echo 'Linus found at: '.$pos;
// Remove from array
unset($myArray[$pos]);
print_r($myArray);
?>