title: Removing an associated key/value pair from array (nested)
body: <p>I have two function to add remove parameters to the query string. The &quot;add_query_params&quot; (thanks to this forum) is working nicely and I can now add multiple tags to the query string of the same type.</p>
  <p>For example</p>
  <pre><code>http://example.com?tags[]=flowers&amp;tags[]=shrubs&amp;category[]=garden
  </code></pre>
  <p>As you can see, I can add multiple of the same parameters, I am also querying these nicely using queryfilters.</p>
  <p>However my newest problem, is simply removing a single tag type without affecting the rest of the query string. I will then rebuild the query without the deleted tag.</p>
  <p>Someone kindly yesterday helped me to to a point but this removes ALL tag key values, not just the specified tag.</p>
  <p>So if I was to delete say <code>$tags[]shrubs</code> from the above URL it would actually delete BOTH <code>tag[]shrubs AND $tags[]flowers</code>.</p>
  <p>This obviously isn't very intuitive for a filter system I am devising. What I would like to know is how to remove just the single key value pair and leave the other keys pairs intact.</p>
  <p>Here is my helper function</p>
  <pre><code>//Accept a param array which passthrough through tag type eg category/tag and value
  function remove_query_params(array $params = [])
  {
      //Set to array
      $existingParams = [];
  
      $existingParams = request()-&gt;query();
  
      foreach($params as $key=&gt;$value){
  
          if (isset($existingParams[$value])) {
              unset($existingParams[$value]);
          }
      }
  
  
      $query = http_build_query($existingParams);
  
      return url()-&gt;current() . '?' . $query;
  }
  
  //Need to return: user removes tag from filter in blade, URL recontructs without the passed through tag value
  //Before
  //http://example.com?tags[]=flowers&amp;tags[]=shrubs&amp;category[]=garden
  
  //After
  //http://example.com?tags[]=flowers&amp;category[]=garden
  </code></pre>
  <p>This does not work, if I change $value to $key then it will will, but it will remove all keys of the same type, not the behaviour I would like.</p>
  <p>I activate this behaviour via a call in the blade template, this forms a href</p>
  <pre><code>//Pass through parameter type and parameter value
  {{remove_query_params(['category' =&gt; $category-&gt;id]) }}
  </code></pre>
  <p>Has anybody got any pointers as to where I go next?#</p>
  <p>Thanks and fingers crossed I am not far off :)</p>
  <p>Adam</p>