- print_r: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$text = <<<'AHA'
ewfda fdffdsfddsa fdsaf ewewem thurn@live.com rewqreqw
fda fdefhgfjh fdsa fdsaf fangorn@hotmail.com rewqr re q rewqrrwq
fda fdfdf dsa fdsaf euice@outlook.com ewrewqre
fd
a f fhjhfdffdsaf fdsa fdsaf rgarcia@optonline.net rewqrewq
fda fdfdsa fdsaf mxiao@yahoo.com rewreqw rewqer
fda fd hffdsa fdsaf firstpr@att.net r ewqrewq
AHA;
$pattern='/\S+@\S+\.\S{1,6}/';
preg_match_all($pattern, $text, $matchArray);
print_r($matchArray[0]);