Logo

Programming-Idioms

History of Idiom 135 > diff from v28 to v29

Edit summary for version 29 by Kaitlyn:
New PHP implementation by user [Kaitlyn]

Version 28

2019-09-27, 15:43:10

Version 29

2019-09-27, 15:44:17

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic. If there are several occurrences of x in items, remove only one of them.

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic. If there are several occurrences of x in items, remove only one of them.

Code
$list_position = array_search($x, $items);
$specific_item = $items[$position];
unset($specific_item);