Published
Updated
Easily manage projects with monday.com
$string = eregi_replace('([_\.0-9a-z-][email protected]([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})','<a href="mailto:\\1">\\1</a>', $text);
echo $string;
All comments are held for moderation. We'll publish all comments that are on topic, not rude, and adhere to our Code of Conduct. You'll even get little stars if you do an extra good job.
You may write comments in Markdown. This is the best way to post any code, inline like `<div>this</div>` or multiline blocks within triple backtick fences (```) with double new lines before and after.
Want to tell us something privately, like pointing out a typo or stuff like that? Contact Us.
Keep in mind that the POSIX Regex functions are deprecated in PHP 5.3.0 and removed in PHP 6.
See http://us2.php.net/manual/en/function.eregi-replace.php
AndiD is right. Use preg_* functions instead of eregi_* functions.
what does this do though? im thinking about making a mail:to link on the footer of my site :
http://attilahajzer.host-ed.net/
take a look and see if it’d be worth it.
Alternatively since eregi_replace is deprecated use preg_replace thus
$stringa = “This should format my email address [email protected]“;
$pattern = “/([a-z0-9][_a-z0-9.-][email protected]([0-9a-z][_0-9a-z-]+\.)+[a-z]{2,6})/i”;
$replace = “\\1“;
$text = preg_replace($pattern, $replace, $stringa);
echo htmlspecialchars($text);
Actually it should be something like
$pattern = “/([a-z0-9][_a-z0-9.-][email protected]([0-9a-z][_0-9a-z-]+\.)+[a-z]{2,6})/i”;
$replace = ‘\\1‘;
$text = preg_replace($pattern, $replace, $stringa);
Actualy it should be something like
$pattern = "/([a-z0-9][_a-z0-9.-][email protected]([0-9a-z][_0-9a-z-]+\.)+[a-z]{2,6})/i";
$replace = '\\1';
$text = preg_replace($pattern, $replace, $stringa);