2011-02-24 54 views

回答

46

With regexp。具體而言,使用preg_replace功能:

$phone = preg_replace('/\D+/', '', $phone); 
+0

真棒。謝謝.. :) – Santosh 2017-06-23 08:58:31

+0

你搖滾!!!!!!!!! – HollerTrain 2017-12-18 18:33:46

11
preg_replace("/[^0-9]/", "", $phone); 
+0

完美 - 清​​理'(555).555-55.55'至'5555555555' – jadeallencook 2015-08-13 15:53:11

2

繁瑣方法爲正則表達式逃避者:

implode(array_filter(str_split("(555) 555-5555", 1), "is_numeric"));