Script de extragere al e-mail

Iata un script simplu de extragere a e-mail-urilor dintr-un  text:

<?php

function extract_emails_from($string){
  preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches);
  return $matches[0];
}

if(isset($_POST['emails'])) {
    $emails = extract_emails_from($_POST['emails']);
    echo "<b>E-mailuri gasite:</b></br> ";
    print(implode("<br/>", $emails));
}

?>

 </br>
 <b>E-mail</b>
<form method="post">
<textarea name="emails"></textarea>
<input type="submit" />
</form>

0 comentarii:

Trimiteți un comentariu