如何使用 PHP 在特殊字符内进行子字符串化?
How to substring within the special character using PHP?
我需要使用 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
我需要使用 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