title: Passing constantly changing query strings PHP
body: <p>I have a list of articles on my page, and I would like to be able to apply a myriad of sorts and filters to it by appending $_GET values to the URL:</p>
  
  <p><a href="http://www.example.com/blogs.php?sort=newest&amp;popularity=high&amp;length=200" rel="nofollow noreferrer">http://www.example.com/blogs.php?sort=newest&amp;popularity=high&amp;length=200</a></p>
  
  <p>If I have links on my page to append these values to the url...they need to be smart enough to account for any previous sorts/filters applied.</p>
  
  <p>EXAMPLE 1:</p>
  
  <p>if i currently have...
  <a href="http://www.example.com/blogs.php?sort=newest" rel="nofollow noreferrer">http://www.example.com/blogs.php?sort=newest</a></p>
  
  <p>and then i want to attach an additional filter of popularity=high, i need to have this:</p>
  
  <p><a href="http://www.example.com/blogs.php?sort=newest&amp;popularity=high" rel="nofollow noreferrer">http://www.example.com/blogs.php?sort=newest&amp;popularity=high</a></p>
  
  <p>and not this:</p>
  
  <p><a href="http://www.example.com/blogs.php?popularity=high" rel="nofollow noreferrer">http://www.example.com/blogs.php?popularity=high</a></p>
  
  <p>EXAMPLE 2:</p>
  
  <p>if i have...
  <a href="http://www.example.com/blogs.php?popularity=high" rel="nofollow noreferrer">http://www.example.com/blogs.php?popularity=high</a></p>
  
  <p>and i try to alter my popularity filter, i do not want:</p>
  
  <p><a href="http://www.example.com/blogs.php?popularity=high&amp;popularity=low" rel="nofollow noreferrer">http://www.example.com/blogs.php?popularity=high&amp;popularity=low</a></p>
  
  <p>so simply tacking on to the query string won't fly.</p>
  
  <p>Therefore, what is a scalable way to build my filter links so that they "remember" old filters, but will still overwrite their own filter value when needed?</p>