Skip to content

Instantly share code, notes, and snippets.

@hipsterjazzbo hipsterjazzbo/

Last active Mar 18, 2019
What would you like to do?
Array intersect but good

PHP's array_intersect throws a fit if you only pass in one array cause it's a whiney baby. This one is good.

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
You can’t perform that action at this time.