title: Using Javascript to get URL Vars, not working when multiple values present in QueryString
body: <p>I am using a Javascript function to get the values of a URL to pass to jQuery using the function below:</p>
  
  <pre><code> function getUrlVars()
      {
          var vars = [], hash;
          var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&amp;');
          for(var i = 0; i &lt; hashes.length; i++)
          {
              hash = hashes[i].split('=');
              vars.push(hash[0]);
              vars[hash[0]] = hash[1];
          }
      return vars;
      }
  </code></pre>
  
  <p>And then setting the value like this:</p>
  
  <pre><code> var type = getUrlVars()["type"]
  </code></pre>
  
  <p>This all works perfectly, however I have just come into a situation where I need to get multiple values, one of my form elements are checkboxes where multiple values can be checked, so my URL will look something like this:</p>
  
  <pre><code> http://www.domain.com/test.php?type=1&amp;cuisine[]=23&amp;cuisine[]=43&amp;name=test
  </code></pre>
  
  <p>If I alert out the cuisine value using the function above I only ever get the final value:</p>
  
  <pre><code> alert (getUrlVars()["cuisine[]"]);
  </code></pre>
  
  <p>Would alert "43".</p>
  
  <p>What I would like it to be is a comma delimited string of all "cuisine" values. ie in the above example "23,43"</p>
  
  <p>Any help very welcome! In case any solution requires it I am using PHP 5.3 and Jquery 1.4</p>