我需要最好的解决方案来从URL获取“标记”。该URL(总是相同的结构)的从URL字符串中分解东西
例子:
https://steamcommunity.com/tradeoffer/new/?partner=123456789&[email protected]
我想只得到[email protected]
从这个网址。
哪个选项是最好的,安全的和更快的做到这一点?
问候。
我需要最好的解决方案来从URL获取“标记”。该URL(总是相同的结构)的从URL字符串中分解东西
例子:
https://steamcommunity.com/tradeoffer/new/?partner=123456789&[email protected]
我想只得到[email protected]
从这个网址。
哪个选项是最好的,安全的和更快的做到这一点?
问候。
您可以使用parse_url
获取查询字符串,然后parse_str
获取token
。
parse_str(parse_url(
'https://steamcommunity.com/tradeoffer/new/?partner=123456789&[email protected]',
PHP_URL_QUERY
), $result);
echo $result['token']; // [email protected]
怎么样?
$arr = explode("=", $string);
echo end($arr); //prints "[email protected]"
仅有代码的答案没有用。请解释这是如何帮助/回答问题的。 –
当然@cale_b会牢记这一点。 –
真棒费德里科,非常感谢。 – mateuszji