title: Conditions within an array in PHP
body: <p>I have a great couple of variables named <code>$value1</code>, <code>$value2</code> etc. I want to create an array <em>key</em> for each variable only if the variable is not empty. Something like this:</p>
  
  <pre><code>$array = array(
      If (!empty($value1)) { "bar" =&gt; "foo", }
      If (!empty($value2)) { "foo" =&gt; "bar", }
  );
  </code></pre>
  
  <p>How do I do this and what would be good practice?</p>