How to trim text using PHP

前端 未结 5 1084
闹比i
闹比i 2020-12-21 01:54

How to trim some word in php? Example like

pid=\"5\" OR pid=\"3\" OR

I want to remove the last OR

5条回答
  •  旧巷少年郎
    2020-12-21 02:21

    A regular expression would also work:

    $str = 'pid="5" OR pid="3" OR';
    print preg_replace('/\sOR$/', '', $str);
    

提交回复
热议问题