Home  >  Article  >  Backend Development  >  PHP code to replace parameter variables in URL

PHP code to replace parameter variables in URL

WBOY
WBOYOriginal
2016-07-25 09:04:21831browse
  1. /**
  2. * Set a certain parameter in the URL to a certain value
  3. * link: bbs.it-home.org
  4. * date: 2013/2/27
  5. */
  6. function url_set_value($url,$key,$value)
  7. {
  8. $a=explode('?',$url);
  9. $url_f=$a[0];
  10. $query=$a[1];
  11. parse_str($query,$arr);
  12. $arr[$key]=$value;
  13. return $url_f.'?'.http_build_query($arr);
  14. }
  15. ?>
复制代码


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn