How to remove all numbers from string?

前端 未结 5 1804
孤街浪徒
孤街浪徒 2020-12-02 16:58

I\'d like to remove all numbers from a string [0-9]. I wrote this code that is working:

$words = preg_replace(\'/0/\', \'\', $words ); // remove numbers
$wor         


        
5条回答
  •  隐瞒了意图╮
    2020-12-02 17:20

    Try with regex \d:

    $words = preg_replace('/\d/', '', $words );
    

    \d is an equivalent for [0-9] which is an equivalent for numbers range from 0 to 9.

提交回复
热议问题