Remove items from one list in another in PHP
PHP: How to remove specific element from an array?
Use
array_search
to get the key and remove it with unset if found:if (($key = array_search('strawberry', $array)) !== false) {
unset($array[$key]);
}
And if there can be multiple items with the same value, you can use
array_keys
to get the keys to all items:foreach (array_keys($array, 'strawberry') as $key) {
unset($array[$key]);
}