我用php代碼抓取URI字符串。 的URI可能是:PHP - 用正則表達式解析字符串
solution 1 - http://www.site.com/one/two/
OR
solution 2 - http://www.site.com/one/two/var_abcdefg.html
OR
solution 3 - http://www.site.com/one/two/var_abcdefg.html?var=123456
OR
solution 4 - http://www.site.com/one/two/?var=123456
我想拆分的字符串:
solution 1:
var 1 = "http://www.site.com/one/two/";
var 2 = "";
var 3 = "";
solution 2:
var 1 = "http://www.site.com/one/two/";
var 2 = "var_abcdefg.html";
var 3 = "";
solution 3:
var 1 = "http://www.site.com/one/two/";
var 2 = "var_abcdefg.html";
var 3 = "?var=123456";
solution 4:
var 1 = "http://www.site.com/one/two/";
var 2 = "";
var 3 = "?var=123456";
我如何能做到嗎?
嘗試['parse_url'](http://php.net/manual/en/function.parse-url.php ) – hakre