Php trim string at a particular character

前端 未结 7 1345
花落未央
花落未央 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:07

    Although pure string functions may give better performance, this is not just a string; it's a URI. Therefore it makes more sense to use a function that's made to handle such data:

    echo parse_url("/gallery/image?a=b", PHP_URL_PATH);
    // Output: /gallery/image
    

提交回复
热议问题