What is the best way to remove punctuation marks, symbols, diacritics, special characters?

前端 未结 2 1752
不知归路
不知归路 2021-01-11 09:30

I use these lines of code to remove all punctuation marks, symbols, etc as you can see them in the array,

$pattern_page = array(\"+\",\",\",\".\",\"-\",\"\'\         


        
2条回答
  •  天涯浪人
    2021-01-11 10:15

    Depending on how greedy you'd like to be, you could do something like:

    $pg_url = preg_replace("/[^a-zA-Z 0-9]+/", " ", $pg_url);
    

    This will replace anything that isn't a letter, number or space.

提交回复
热议问题