Remove everything except letters from PHP string

后端 未结 3 693
傲寒
傲寒 2020-12-07 01:10

How can I remove everything from a string apart from letters? I have an input field for first names.

3条回答
  •  时光说笑
    2020-12-07 02:04

    In PHP, you can use (as suggested by @rczajka and @mario):

    preg_replace('/\PL/u', '', $str)
    

    Working Example: http://codepad.viper-7.com/V78skl

    You may want to checkout this Tutorial for regex

提交回复
热议问题