开发者

PHP, replace url query var's value

开发者 https://www.devze.com 2023-01-23 13:16 出处:网络
site.com/page1.php?a=1&b=2,how to replace a=1 to a=3? and get a new url st开发者_如何学运维ring.Use parse_str to extract the values into an array, alter them, and emit with http_build_query:

site.com/page1.php?a=1&b=2,how to replace a=1 to a=3? and get a new url st开发者_如何学运维ring.


Use parse_str to extract the values into an array, alter them, and emit with http_build_query:

$query = "a=1&b=2";
parse_str($query, $vals);
$vals['a'] = '3';
$fixed_query = http_build_query($vals);

parse_str docs: http://php.net/manual/en/function.parse-str.php

http_build_query: http://www.php.net/manual/en/function.http-build-query.php

0

精彩评论

暂无评论...
验证码 换一张
取 消