Allow only [a-z][A-Z][0-9] in string using PHP

前端 未结 6 1534
栀梦
栀梦 2020-11-28 14:38

How can I get a string that only contains a to z, A to Z, 0 to 9 and some symbols?

6条回答
  •  醉酒成梦
    2020-11-28 14:59

    You can filter it like:

    $text = preg_replace("/[^a-zA-Z0-9]+/", "", $text);
    

    As for some symbols, you should be more specific

提交回复
热议问题