PHP's array_intersect
throws a fit if you only pass in one array cause it's a whiney baby. This one is good.
Last active
March 18, 2019 01:24
-
-
Save hipsterjazzbo/b8a7fd4d7b8fb11add6556cdc879b613 to your computer and use it in GitHub Desktop.
Array intersect but good
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
<?php | |
function array_intersect_good(array $arrays): array | |
{ | |
if (count($arrays) === 1) { | |
return $arrays; | |
} | |
return array_intersect(...$arrays); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment