Filters out the elements of an array, that have one of the specified values.
Use array_values()
and array_diff()
to remove any values in $params
from $items
.
代码实现
function without($items, ...$params)
{
return array_values(array_diff($items, $params));
}
使用样例
without([2, 1, 2, 3], 1, 2); // [3]