<td>example@example.com</td>
<td><a href="example@example.com">example@example.com</a></td>
<?php$content ='<table><tr><td>example@example.com</td><td>example@example.co.uk</td></tr></table>';$addr_pattern = '/([A-Z0-9._%+-]+)@([A-Z0-9.-]+)\.([A-Z]{2,4})(\((.+?)\))?/i';preg_match_all($addr_pattern, $content, $addresses);$the_addrs = $addresses[0];for ($a = 0; $a < count($the_addrs); $a++) { $repaddr[$a] = preg_replace($addr_pattern, '<a href="mailto:$1@$2.$3">$1@$2.$3</a>', $the_addrs[$a]); } $cc = str_replace($the_addrs, $repaddr, $content); echo $cc; ?>
And I want to have php make that into this:
If necessary, I could use javascript, but I'd like to keep this to the server-side.
based on : http://stackoverflow.com/questions/5068676/regex-to-detect-plain-email-and-mailto-link-emails