How to display clickable phone in the correct format?

There is a code
<a href="tel: <? include($_SERVER["DOCUMENT_ROOT"]."/include/iphone.php");?>"><? include($_SERVER["DOCUMENT_ROOT"]."/include/iphone.php"); ?></a>

Displays a phone like this
<a href="tel:8 (922) 22-22-222">8 (922) 22-22-222</a>

And it is necessary to output
<a href="tel:89222222222">8 (922) 22-22-222</a>
That is only numbers with no spaces. Help, broke my head))
The contents of the file iphone.php text, there is no code, just phone:
8 (922) 22-22-222
March 23rd 20 at 19:37
3 answers
March 23rd 20 at 19:39
Solution
<a href="tel:<? echo(preg_replace("/[^\d]+/s", "", file_get_contents($_SERVER["DOCUMENT_ROOT"]."/include/iphone.php")));?>"><? readfile($_SERVER["DOCUMENT_ROOT"]."/include/iphone.php"); ?></a>
The coolest answer - concisely and accurately.
rashad_Corkery @rashad_Corkery - hammer!
In the Glass suggested the use of a custom stream filter (don't even know what it is) works too, but the code for the whole page. - eunice.Zboncak commented on March 23rd 20 at 19:42
March 23rd 20 at 19:41
Cut out everything except digits
$phone = '8 (922) 22-22-222';
echo preg_replace('[\D]', ", $phone); // 89222222222
March 23rd 20 at 19:43
To format a phone number use
/**
 * To format the phone number to display in the link (string)
 * $var - phone number (string)
*/
 phone_link function($var){
 $res = preg_replace('/\D/', ", $var);
 $first = substr($res, 0, 1);
 if($first == 7) $res = '+'.$res;
 return $res;
}

Find more questions by tags PHP