title: Inserting only unique values into an array
body: <p>I have a set of values that I'm pushing into an array in the order they occur  </p>
  
  <pre><code>$valsArray = array(); 
  
  //I process each value from a file (code removed for simplicity) 
  //and then add into the array 
  $valsArray[] = $val; 
  </code></pre>
  
  <p>How do I turn this into an associative array instead where the value gets inserted (as <code>$key of associative array</code>) only if it doesn't exist. If it does exist increment its count (<code>$value of associative array</code>) by 1. I'm trying to find a more efficient way of handling those values compared to what I'm doing now. </p>