First off, thank you so much for this! I wanted to drop a note in here to see if you thought it would be quickly doable to extend this to also replace phone numbers. I'm currently doing this with my own simple regex and preg_replace. Would be so cool to have it in here as well!
First off, thank you so much for this! I wanted to drop a note in here to see if you thought it would be quickly doable to extend this to also replace phone numbers. I'm currently doing this with my own simple regex and preg_replace. Would be so cool to have it in here as well!
My second rate PHP:
function autolink_phone($text) { $text = preg_replace("/\d?(\s?|-?|\+?|\.?)((\(\d{1,4}\))|(\d{1,3})|\s?)(\s?|-?|\.?)((\(\d{1,3}\))|(\d{1,3})|\s?)(\s?|-?|\.?)((\(\d{1,3}\))|(\d{1,3})|\s?)(\s?|-?|\.?)\d{3}(-|\.|\s)\d{4}/i", "<a href=\"tel:$0\" target='_blank'>$0</a>", $text); return ($text); }