I have the following piece of code...
public function setEmailAddresses() {
$this->matches = array();
$this->matchRegex = '/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}/';
preg_match_all($this->matchRegex, $this->getSearchResults(), $this->matches);
$this->emailAddresses = array_values($this->matches[0]);
}
Now I want to take the e-mail addresses in the array, and remove any array entries that are redundant. Restated, if the same email address is found in the array three times, I want to reduce it down to only being present once. Can someone help me accomplish this?
Also, is that the best regex to use for identifying an email address? It is working for me, but I want to know if there is a better one I should use?
Thanks in advance for your help!