I want to create plugin that finds and replaces phone numbers with a linked number for mobile. This is a php function that I have written for Joomla to use to replace a phone number...
protected function clickToCall(&$text, &$params){
// phone number pattern...
$pattern = '~(\+0?1\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}~';
//replacement pattern...
$replacement = '<a href="tel:$1$2">$1$2</a>';
//use preg_replace to actually replace the pattern
$text = preg_replace($pattern, $replacement, $text);
//return the new value
return true;
}
Right now the function finds the pattern and just replaces it with an empty link. How can insert the phone number found by regex into a link?