30 seconds of PHP

  Back to Home

reject

arraybeginner

Filters the collection using the given callback.

Use array_values(), array_diff() and array_filter() to filter $items based on $func.

function reject($items, $func)
{
  return array_values(array_diff($items, array_filter($items, $func)));
}