Created
October 15, 2020 16:15
-
-
Save rentalhost/e37628db9b3dc8e737c6b9153d617200 to your computer and use it in GitHub Desktop.
array_subtract()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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