/ Published in: PHP
Extract email addresses from submitted text or a full URL
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php ?> <form method="post"> Please enter full URL of the page to parse (including http://):<br /> <input type="text" name="url" size="65" value="<?php echo $the_url; ?>"/><br /> or enter text directly into textarea below:<br /> <textarea name="text" cols="50" rows="15"></textarea> <br /> <input type="submit" value="Parse Emails" /> </form> <?php // fetch data from specified url } // get text from text area $text = $_REQUEST['text']; } // parse emails "/[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}/i", $text, $matches ); if ($res) { echo $email . "<br />"; } } else { echo "No emails found."; } } ?>