title: PHP Ternary statement within Associative Array to set both key & value?
body: <p>I've been searching and testing for some time and just can't find if what I am trying to accomplish is possible the way I'm going about it.</p>
  
  <p>I would like to add a key/value pair to an array, when defining the array, based on an ternary statement.</p>
  
  <pre><code>Array(
      'Item 1' =&gt; 'Some value',
      (FALSE)? NULL : 'Item 2' =&gt; 'Another Value'
  )
  </code></pre>
  
  <p>My expected/wanted behavior is for the result to then be:</p>
  
  <pre><code>Array (
    [Item 1] =&gt; Some value
    [Item 2] =&gt; Another Value
  )
  </code></pre>
  
  <p>And when the statement is True:</p>
  
  <pre><code>Array(
      'Item 1' =&gt; 'Some value',
      (TRUE)? NULL : 'Item 2' =&gt; 'Another Value'
  )
  </code></pre>
  
  <p>Yield:</p>
  
  <pre><code>Array (
    [Item 1] =&gt; Some value
  )
  </code></pre>
  
  <p>But instead I get:</p>
  
  <pre><code>Array (
    [Item 1] =&gt; Some value
    [] =&gt; Another Value
  )
  </code></pre>
  
  <p>Which causes problems since A) I don't want this second element to exist in the first place and B) The False condition value is assigned to the True conditions value (in this case NULL, which sets the key to NULL [])</p>
  
  <p>This is very peculiar. Is my only option to have a standard if(){} statement and Pop the element if the condition is false (by using !) into the array?</p>
  
  <p>Note: Having a null value for Item 2 is not acceptable, rather if the initial condition is true, no element should exist at all.</p>
  
  <p>Any help would be greatly appreciated!</p>