Php 将电话号码格式转换为普通号码

Php 将电话号码格式转换为普通号码,php,converter,Php,Converter,我有一些电话格式的变量,如以下变量: $phone1 = "(123) 123-1234"; $phone2 = "+1234567892"; $phone3 = "123-434-3432 $new_phone1 = "1231231234"; $new_phone2 = "1234567892"; $new_phone3 = "1234343432"; 如何在php中将这些变量转换为纯数字 结果应类似于以下变量: $phone1 = "(123) 123-1234"; $phone2 =

我有一些电话格式的变量,如以下变量:

$phone1 = "(123) 123-1234";
$phone2 = "+1234567892";
$phone3 = "123-434-3432
$new_phone1 = "1231231234";
$new_phone2 = "1234567892";
$new_phone3 = "1234343432";
如何在php中将这些变量转换为纯数字

结果应类似于以下变量:

$phone1 = "(123) 123-1234";
$phone2 = "+1234567892";
$phone3 = "123-434-3432
$new_phone1 = "1231231234";
$new_phone2 = "1234567892";
$new_phone3 = "1234343432";

使用preg_replace,它使用正则表达式

preg_替换(“/[^0-9]/”、“,'123-434-3432”)

删除除数字以外的所有内容