Answers.Body: <p>Yeah, looks like Craft's <a href="https://craftcms.com/docs/templating/functions#url" rel="nofollow"><code>url()</code></a> method doesn't support nested array syntax for querystring params.</p>
  
  <p>If you still want to use it, then you'd need to flatten it with unique keys such as:</p>
  
  <pre><code>Array
  (
      [q] =&gt; 
      [cat] =&gt; 
      [city0] =&gt; 28
      [city1] =&gt; 26
      [sort] =&gt; asc
      [order] =&gt; name
  )
  </code></pre>
  
  <p>Alternatively you can manually build the URL yourself in Twig in whatever format you'd like.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-16T21:57:20.147Z
Answers.LastActivityDate: 2016-05-16T21:57:20.147Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have a list of checkboxes in a GET form which results in a URL with a querystring like <code>?q=&amp;cat=&amp;city%5B%5D=28&amp;city%5B%5D=26&amp;sort=asc&amp;order=name</code> when submitted. The Object/Array behind this string looks like:</p>
  
  <pre><code>Array
  (
      [q] =&gt; 
      [cat] =&gt; 
      [city] =&gt; Array
          (
              [0] =&gt; 28
              [1] =&gt; 26
          )
      [sort] =&gt; asc
      [order] =&gt; name
  )
  </code></pre>
  
  <p>I'm trying to create a link with one of those GET params changed, but I can't find a way to update a single value. So now I'm rebuilding the URL by creating an object based on the given query params.</p>
  
  <p>If I pass this object (as shown above) to the second argument inside Craft's <a href="https://craftcms.com/docs/templating/functions#url" rel="nofollow"><code>url()</code></a> function to use this URL on a simple <code>&lt;a&gt;</code> tag, I get an <code>Array to string conversion</code> error.</p>
  
  <p>I seems Craft can't handle nested arrays in this function. Is there another method to generate an URL from such an object?</p>
  
Tags: <url><array>
Title: Pass a nested array to the params argument inside Craft's url() function
ThreadText: # Pass a nested array to the params argument inside Craft's url() function
  
  (Asked by: username_0 on 2016-05-16)
  
  I have a list of checkboxes in a GET form which results in a URL with a querystring like `?q=&cat=&city%5B%5D=28&city%5B%5D=26&sort=asc&order=name` when submitted. The Object/Array behind this string looks like:
  
  ```
  Array
  (
      [q] => 
      [cat] => 
      [city] => Array
          (
              [0] => 28
              [1] => 26
          )
      [sort] => asc
      [order] => name
  )
  
  ```
  
  I'm trying to create a link with one of those GET params changed, but I can't find a way to update a single value. So now I'm rebuilding the URL by creating an object based on the given query params.
  
  If I pass this object (as shown above) to the second argument inside Craft's [`url()`](https://craftcms.com/docs/templating/functions#url) function to use this URL on a simple `<a>` tag, I get an `Array to string conversion` error.
  
  I seems Craft can't handle nested arrays in this function. Is there another method to generate an URL from such an object?
  
  **Tags:** url, array
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-05-16. Score: 1
  
  Yeah, looks like Craft's [`url()`](https://craftcms.com/docs/templating/functions#url) method doesn't support nested array syntax for querystring params.
  
  If you still want to use it, then you'd need to flatten it with unique keys such as:
  
  ```
  Array
  (
      [q] => 
      [cat] => 
      [city0] => 28
      [city1] => 26
      [sort] => asc
      [order] => name
  )
  
  ```
  
  Alternatively you can manually build the URL yourself in Twig in whatever format you'd like.
  
  
  ---
  
  