<?php
$text = "Sample text for testing:
abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789 +-.,!@#$%^&*();\/|<>'
12345 -98.7 3.141 .6180 9,000 +42
555.123.4567 +1-(800)-555-2468
foo@demo.net bar.ba@test.co.uk
www.demo.com http://f...content-available-to-author-only...o.uk/
http://r...content-available-to-author-only...r.com/foo.html?q=bar
mail@mail.ru waka@wak.rc.uk
user0+test+hello_world@100500.com
user%office@company.com
BIGBOSS@BIGCOMPANY.COM
";
function grabEmail($text) { //между названием функции и () не ставится пробел.
$emailRegexp = '/[\w\.%_\+-]+@[\w\._-]+/i';
$matches = [];
$count = preg_match_all($emailRegexp, $text, $matches, PREG_SET_ORDER
); foreach ($matches as $emails) {
$mail[] = $emails[0];
echo "$emails[0]\n";
}
return $mail;
}
grabEmail($text);
PD9waHAKZXJyb3JfcmVwb3J0aW5nKC0xKTsKCiR0ZXh0ID0gIlNhbXBsZSB0ZXh0IGZvciB0ZXN0aW5nOgphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5eiBBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWgowMTIzNDU2Nzg5ICstLiwhQCMkJV4mKigpO1wvfDw+JwoxMjM0NSAtOTguNyAzLjE0MSAuNjE4MCA5LDAwMCArNDIKNTU1LjEyMy40NTY3CSsxLSg4MDApLTU1NS0yNDY4CmZvb0BkZW1vLm5ldAliYXIuYmFAdGVzdC5jby51awp3d3cuZGVtby5jb20JaHR0cDovL2YuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLm8udWsvCmh0dHA6Ly9yLi4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5yLmNvbS9mb28uaHRtbD9xPWJhcgptYWlsQG1haWwucnUgd2FrYUB3YWsucmMudWsKdXNlcjArdGVzdCtoZWxsb193b3JsZEAxMDA1MDAuY29tCnVzZXIlb2ZmaWNlQGNvbXBhbnkuY29tCkJJR0JP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