How to remove all numbers from string?

前端 未结 5 1803
孤街浪徒
孤街浪徒 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:16

    Use some regex like [0-9] or \d:

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

    You might want to read the preg_replace() documentation as this is directly shown there.

提交回复
热议问题