Php trim string at a particular character

前端 未结 7 1386
花落未央
花落未央 2021-01-11 18:32

Is there a php string function to trim a string after a particular character. I had a look on the php.net site and did a google search but couldn\'t find anything. The only

7条回答
  •  南方客
    南方客 (楼主)
    2021-01-11 19:16

    Maybe something like this:

    $string = substr($string, 0, strpos($string, '?'));
    

    Note that this isn't very robust (i.e. no error checking, etc), but it might help you solve your problem.

提交回复
热议问题