Skip to content

Instantly share code, notes, and snippets.

@rentalhost
Created October 15, 2020 16:15
Show Gist options
  • Save rentalhost/e37628db9b3dc8e737c6b9153d617200 to your computer and use it in GitHub Desktop.
Save rentalhost/e37628db9b3dc8e737c6b9153d617200 to your computer and use it in GitHub Desktop.
array_subtract()
function array_subtract(array $source, array $subtractor)
{
foreach ($subtractor as $subtractorItem) {
$subtractorKey = array_search($subtractorItem, $source, true);
if ($subtractorKey !== false) {
unset($source[$subtractorKey]);
}
}
return array_values($source);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment