I need to remove all email and phone number from string in PHP. Can someone help me on this?
This is just for a start up not a complete answer. You need to read more about regular expressions and its usage.
remove email addresses :
$pattern = "/[^@\s]*@[^@\s]*\.[^@\s]*/";
$replacement = "[removed]";
preg_replace($pattern, $replacement, $string);
For phone numbers :
$text = preg_replace('/\+?[0-9][0-9()-\s+]{4,20}[0-9]/', '[removed]', $text);
this looks for:
a plus symbol (optional), followed by a number, followed by between 4-20 numbers, brackets, dashes or spaces, followed by a number
and replaces with the string [removed].