doutuan4361 2017-04-04 07:19
浏览 80
已采纳

如何使用PHP在特殊字符内子串?

I need to sub-string the value within some special character using PHP. I am explaining the original string below.

"name=G%20+%20l&cid=20"

In the above string I need the value within name= to next &.

  • 写回答

1条回答 默认 最新

  • doupa9062 2017-04-04 07:24
    关注

    Try this:

    $string = "name=G%20+%20l&cid=20";
    $explode_string = explode("&", $string);
    
    $explode_string2 = explode("name=", $explode_string[0]);
    echo array_pop($explode_string2);
    

    Output will be like:

    G%20+%20l
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?