Skip to content

Instantly share code, notes, and snippets.

@dmshvetsov
Created May 15, 2014 07:40
Show Gist options
  • Save dmshvetsov/19f55c9bd195c9347bb1 to your computer and use it in GitHub Desktop.
Save dmshvetsov/19f55c9bd195c9347bb1 to your computer and use it in GitHub Desktop.
Make tel: anchor tags from telephones string
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