How to trim text using PHP

前端 未结 5 1096
闹比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:06

    Using substr to find and remove the ending OR:

    $string = "pid='5' OR pid='3' OR";
    if(substr($string, -3) == ' OR') {
      $string = substr($string, 0, -3);
    }
    echo $string;
    

提交回复
热议问题