I have an associative array of headers and I need to throw an exception if there are duplicate values:
Array
(
[0] => Email
[1] => Name
[2] => Something
[3] => Else
[4] => Email
)
What's the best way to catch that there are two or more Email values? array_values is not getting the values. I don't want array_unique, as I want to abort if there are multiples.
array_count_values()What do you want to do if you catch them? Wrapping it inarray_filter()to check for those > 1 or == 1 is probably where I would take it.array_count_values()is I can't guarantee that the array will not have null values. That only counts strings and integers.