title: PHP: How to dynamically add to http_build_query?
body: <p>I have a scraping object basically. I want to be able to add POST variables to it like</p>
  
  <pre><code>$obj-&gt;addvar('Name', 'Value');
  </code></pre>
  
  <p>What I have now is this:</p>
  
  <pre><code>  function addvar($var, $val) {
      $postvars[] = Array($var=&gt;$val); 
    }
    function initiate() {
      $this-&gt;q = $postvars;
    }
    if(!empty($this-&gt;post)) {
      $this-&gt;params = http_build_query($q);
    }
  </code></pre>
  
  <p>I haven't tested because it's too incomplete, But would my addvar() function work? How on earth do I append a key+value to the array so http_build_query would accept it? </p>
  
  <p>IE (this is what I want):</p>
  
  <pre><code>$obj-&gt;addvar('username', 'abc');
  $obj-&gt;addvar('password', 'foobar');
  $obj-&gt;send(); //..
  </code></pre>