1
site.com/page1.php?a=1 & b = 2,如何將a = 1替換爲a = 3?並獲得一個新的url字符串。PHP,替換url查詢var的值
site.com/page1.php?a=1 & b = 2,如何將a = 1替換爲a = 3?並獲得一個新的url字符串。PHP,替換url查詢var的值
使用parse_str
提取值到一個數組,改變它們,並用http_build_query
發射:
$query = "a=1&b=2";
parse_str($query, $vals);
$vals['a'] = '3';
$fixed_query = http_build_query($vals);
parse_str文檔:http://php.net/manual/en/function.parse-str.php
http_build_query:http://www.php.net/manual/en/function.http-build-query.php