Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $text = "Ngày thử nhất tôi đăng ký một cái email là first@gmail.com, ngày thứ hai tôi đăng ký là second@gmail.com";
- $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) {
- // array_unique loại bỏ các phần từ nào trùng nhau
- foreach(array_unique($matches[0]) as $email) {
- echo $email . "";
- }
- }
- // Kết quả:
- // first@gmail.com
- // second@gmail.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement