我想删除php中字符串中的所有字符/字符串中的整数


I want to remove all charactors from string /integer from string in php

我想从字符串中删除字符和整数。

假设它是字符串:Tel. 040- 36 49 03 SEC。如何删除上面字符串中的所有字符?

我正在使用

$string='Tel.  040- 36 49 03 SEC';
$mobileString=trim(str_replace(range(0,9),'',$string));
$mobileNumber=trim(chop($string,$mobileString));

它并没有完全按照我的需要工作。

试试这个:

$string='Tel. 040- 36 49 03 SEC';
echo preg_replace("/[A-Za-z]+/","",$string);

是否也要删除.-

echo preg_replace("/[A-Za-z'-'. ]+/","",$string); // this will just give you number, removes all characters

试试这个:

$words = preg_replace('/[0-9'-]+/', '', $string);