title: remove duplicate arrays in loop
body: <p>I have an associative array that might contain duplicates. I am trying to loop through the array and compare the current element with the next element in the array. If there is a duplicate, it should be removed. </p>
  
  <p>The code below removes one instance of the element. In the test array I'm using, I have 3 duplicate part numbers, but my code only removes one. I'm left with two. I only want one to remain.</p>
  
  <pre><code>  $length = count($items);
  
     for($i = 0; $i &lt; $length -1; $i++){
      if($items[$i]['part_number'] == $items[$i+1]['part_number']){
        unset($items[$i+1]);
        $items = array_values($items);
      }
     }
  </code></pre>
  
  <p>What am I doing wrong here?</p>