Created
May 15, 2014 07:40
-
-
Save dmshvetsov/19f55c9bd195c9347bb1 to your computer and use it in GitHub Desktop.
Make tel: anchor tags from telephones string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function telLinkTag($str = '') { | |
$delimeter = ', '; | |
$tels = explode($delimeter, $str); | |
$res = array(); | |
foreach($tels as $tel) { | |
$invalidChar = array('(', ')', ' ', '-'); | |
array_push($res, '<a href="' . | |
'tel:+' . str_replace($invalidChar, '', $tel) . | |
'">' . | |
$tel . | |
'</a>'); | |
} | |
return implode($delimeter, $res); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment