title: php unique/group associative array
body: <p>I would like to remove duplicates for the following array. I want to group by the first value and then rebuild the index.</p>
  
  <p>ie</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [title] =&gt; California
              [state_id] =&gt; 1
          )
  
      [1] =&gt; Array
          (
              [title] =&gt; California
              [state_id] =&gt; 1
          )
  
      [2] =&gt; Array
          (
              [title] =&gt; New Mexico
              [state_id] =&gt; 2
          )
  
      [3] =&gt; Array
          (
              [title] =&gt; Washington
              [state_id] =&gt; 3
          )
  
      [4] =&gt; Array
          (
              [title] =&gt; Montana
              [state_id] =&gt; 4
          )
  
      [5] =&gt; Array
          (
              [title] =&gt; Montana
              [state_id] =&gt; 4
          )
  )
  </code></pre>
  
  <p>To</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [title] =&gt; California
              [state_id] =&gt; 1
          )
  
  [2] =&gt; Array
      (
          [title] =&gt; New Mexico
          [state_id] =&gt; 2
      )
  
  [3] =&gt; Array
      (
          [title] =&gt; Washington
          [state_id] =&gt; 3
      )
  
  [4] =&gt; Array
      (
          [title] =&gt; Montana
          [state_id] =&gt; 4
      )
  
  )
  </code></pre>
  
  <p>and rebuild key</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [title] =&gt; California
              [state_id] =&gt; 1
          )
  
      [1] =&gt; Array
          (
              [title] =&gt; New Mexico
              [state_id] =&gt; 2
          )
  
      [2] =&gt; Array
          (
              [title] =&gt; Washington
              [state_id] =&gt; 3
          )
  
      [3] =&gt; Array
          (
              [title] =&gt; Montana
              [state_id] =&gt; 4
          )
  
  )
  </code></pre>