how to strip punctuation in php

后端 未结 6 1386
长发绾君心
长发绾君心 2021-02-01 22:45

How can I strip punctuation except for these characters . = $ \' - %

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-01 23:15

    Demo here

    or, of course, shorter :

    $test = str_replace(array("?","!",",",";"), "", $test);
    

    Source from 1st example of str_replace manual

提交回复
热议问题