0
如何使用preg_match从URL获取查询字符串?使用正则表达式解析查询字符串的PHP
http://www.example.com/imgres?imgurl=http://www.example.com/images/blue-diamond-rings.jpg
我要如何使用preg_matches
从上面的网址 'imgUrl的'?
如何使用preg_match从URL获取查询字符串?使用正则表达式解析查询字符串的PHP
http://www.example.com/imgres?imgurl=http://www.example.com/images/blue-diamond-rings.jpg
我要如何使用preg_matches
从上面的网址 'imgUrl的'?
PHP具有解析URL和查询字符串的功能,您不需要使用正则表达式。
$parts = parse_url("http://www.mysite.com/imgres?imgurl=http://www.mysite.com/images/blue-diamond-rings.jpg");
$query_string = $parts['query'];
parse_str($query_string, $output);
echo $output['imgurl'];
感谢您的帮助 – 2010-12-21 14:13:55