Tag: extract information

How to extract emails from a webpage in PHP?

Sometimes we need to extract the emails contained in a piece of text or html document. Here you can find a simple script that extracts unique emails from a webpage. 123456789101112131415161718192021222324<?         function get_emails_from_webpage($url)     {       $text=file_get_contents($url);       $res = preg_match_all("/[a-z0-9]+[_a-z0-9\.-]*[a-z0-9]+@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})/i",$text,$matches);       if ($res) {           return array_unique($matches[0]);       }       else{         […]