I have a block of text from which I want to extract the valid e-mail addresses and put them into an array. So far I have...
$string = file_get_contents(\
I know this is not the question you asked but I noticed that your regex is not accepting any address like 'myemail@office21.company.com
' or any address with a subdomain. You could replace it with something like :
/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}/
which will reject less valid e-mail (although it is not perfect).
I also suggest you read this article on e-mail validation, it is pretty good and informative.