title: add to array if it isn't there already
body: <p>How do I add elements to an array only if they aren't in there already? I have the following:</p>
  
  <pre><code>$a=array();
  // organize the array
  foreach($array as $k=&gt;$v){
      foreach($v as $key=&gt;$value){
          if($key=='key'){
          $a[]=$value;
          }
      }
  }
  
  print_r($a);
  </code></pre>
  
  <p>// Output</p>
  
  <pre><code>Array
  (
  [0] =&gt; 1
  [1] =&gt; 2
  [2] =&gt; 3
  [3] =&gt; 1
  [4] =&gt; 2
  [5] =&gt; 3
  [6] =&gt; 4
  [7] =&gt; 5
  [8] =&gt; 6
  
  )
  </code></pre>
  
  <p>Instead, I want $a to consist of the unique values. (I know I can use array_unique to get the desired results but I just want to know)</p>