30 seconds of PHP

  Back to Home

pull

arraybeginner

Mutates the original array to filter out the values specified.

Use array_values() and array_diff() to remove the specified values from $items.

function pull(&$items, ...$params)
{
  $items = array_values(array_diff($items, $params));
  return $items;
}