如何在URL字符串中显示任何url模式(How to get any url pattern present in URL string)

系统教程 行业动态 更新时间:2024-06-14 17:03:54
如何在URL字符串中显示任何url模式(How to get any url pattern present in URL string)

我需要从给定的url字符串中获取url值,例如我在url下面

$url = http://www.example.com/news?q=string&f=true&id=1233&sort=true&pf=http%3A%2Fo%2fox.ru

从上面的url如果有任何url存在意味着我需要该值,上面不是常量,随机我得到任何格式的url,但我只需要来自给定URL字符串的url。我在这里参考如何从URL字符串中获取参数? 。 因为他们使用静态参数,但我不知道哪个参数具有url值。 任何帮助表示赞赏。

I need to get url value form the given url string, for example I have below url

$url = http://www.example.com/news?q=string&f=true&id=1233&sort=true&pf=http%3A%2Fo%2fox.ru

from above url if any url is present means I need that value, above is not constant, randomly I get any format of url , But I need only the url from the given URL string.I reffered here How to get parameters from a URL string?. In that they use static parameter , but I dont know which parameter have the url value. Any help is appreciated.

最满意答案

<?php $url = "http://www.example.com/news?q=string&f=true&id=1233&sort=true&pf=http%3A%2Fo%2fox.ru"; parse_str(parse_url($url, PHP_URL_QUERY), $output); echo print_r($output, TRUE); ?>

您也可以使用此代码。

<?php $url = "http://www.example.com/news?q=string&f=true&id=1233&sort=true&pf=http%3A%2Fo%2fox.ru"; parse_str(parse_url($url, PHP_URL_QUERY), $output); echo print_r($output, TRUE); ?>

You can also use this code.

更多推荐

url,URL,value,电脑培训,计算机培训,IT培训"/> <meta name="description&quo

本文发布于:2023-04-24 14:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/99c5891a568bd665904e22bf1b97d432.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   模式   如何在   URL   url

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!