php去除字符串中數(shù)字的方法:
這個(gè)比較簡(jiǎn)單,但是也有些需要注意的地方,先貼代碼
$class=preg_replace("\d+",'', $res);
需要使用preg_replace函數(shù),但是只是這么寫(xiě)的話,會(huì)報(bào)錯(cuò)
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash
翻譯過(guò)來(lái)就是定界符不能是字母數(shù)字或反斜線。
想了一下,在正則表達(dá)式首尾加了一對(duì)/
$class=preg_replace("/\d+/",'', $res);
這樣就成功了
相關(guān)參考:php中文網(wǎng)