Posts Tagged ‘replace . in string’

Have you ever faced issue with your hosting server when you send html email with some email addresses in it? Replace your string with the following php regular expression.


//Html string you want to replace
$html_message=    “Its sample message with two email address in it. and”;

//Cleaned string
$cleaned_message = preg_replace(‘/\b([A-Z0-9._%+-]+@[A-Z0-9.-]+)(\.)([A-Z]{2,4}\b)/i’, ‘$1.$3’, $html_message);

echo $cleaned_message;