Remove everything after a character in PHP

后端 未结 8 2766
无人共我
无人共我 2021-02-19 08:09

can any tell how to remove characters after ? in php. I have one string test?=new i need to remove the characters as well as = from that string.

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-19 08:31

    Shortest one:

    echo strtok('test?=new', '?');
    

    If you want to keep the question mark, the solution is almost the same:

    echo strtok('test?=new', '?').'?';
    

提交回复
热议问题