Hi I have an array of email addresses.
What I would like to do is search this array to see if there are multiples of the same email address, so I can then return an error.
Is there a function that allows you to do this?
thanks in advance.
checking for multiple values within an array
Moderator: General Moderators
Code: Select all
if (count($array) !== count(array_unique($array))) echo 'Duplicates detected!';- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
Or, as you are loading the addresses into the array:
will potentially find duplicates before the entire array is loaded.
Code: Select all
if(in_array($thisEmail, $emailAddresses)) { echo "duplicate found"; exit; }