如何使用PHP在特殊字符中创建子字符串?

如何使用PHP在特殊字符中创建子字符串?,php,substr,Php,Substr,我需要使用PHP在一些特殊字符中对值进行子字符串化。我在下面显示原始字符串 "name=G%20+%20l&cid=20" 在上面的字符串中,我需要name=到下一个&中的值,请尝试以下操作: $string = "name=G%20+%20l&cid=20"; $explode_string = explode("&", $string); $explode_string2 = explode("name=", $explode_string[0]); echo a

我需要使用PHP在一些特殊字符中对值进行子字符串化。我在下面显示原始字符串

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

在上面的字符串中,我需要
name=
到下一个
&
中的值,请尝试以下操作:

$string = "name=G%20+%20l&cid=20";
$explode_string = explode("&", $string);

$explode_string2 = explode("name=", $explode_string[0]);
echo array_pop($explode_string2);
输出如下所示:

G%20+%20l

如果这是来自请求URL,那么
$\u GET['name']
不,我的一般字符串是这样的;比使用explodeOutput好得多的应该是
G%20+%20l