【发布时间】:2012-07-13 21:51:39
【问题描述】:
我有一个 HTML 表单字段 $_POST["url"],其中包含一些 URL 字符串作为值。
示例值为:
https://example.com/test/1234?email=xyz@test.com https://example.com/test/1234?basic=2&email=xyz2@test.com https://example.com/test/1234?email=xyz3@test.com https://example.com/test/1234?email=xyz4@test.com&testin=123 https://example.com/test/the-page-here/1234?someurl=key&email=xyz5@test.com等等
如何才能从这些 URL/值中仅获取 email 参数?
请注意,我没有从浏览器地址栏中获取这些字符串。
【问题讨论】:
-
我有点困惑,请详细说明问题...
-
您是在说/要求将 URL 视为字符串吗?
-
如果您想从字符串中“匹配”电子邮件部分,就像在您的示例中一样,请使用正则表达式。可以像
/(email=\w\@\w\.\w)/或更高级的匹配技术一样简单。只是给你的想法。见preg_match函数:php.net/manual/en/function.preg-match.php -
Get URL query string的可能重复
标签: php url-parsing