-1

I want to filter those messages ( a long text string ) if it contains any personal information ( email ) in PHP. Is there a built-in function in PHP or if anybody has experienced filtering like this, I would be thankful with.

Thanks !

Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46
Ishwor
  • 3
  • 1
  • Is this helps? http://stackoverflow.com/questions/16424659/check-if-a-string-contains-an-email-address – Amit Rajput Dec 29 '15 at 07:00
  • Possible duplicate of [Mass of text, cherry pick email addresses](http://stackoverflow.com/questions/2335124/mass-of-text-cherry-pick-email-addresses) – Mohammad Dec 29 '15 at 07:02

1 Answers1

0

You can search and replace emails with another string:

$str = preg_replace('/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})/', '[censored]', $str);

Saman Mohamadi
  • 4,454
  • 4
  • 38
  • 58