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.
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.
  $length = count($items);
   for($i = 0; $i < $length -1; $i++){
    if($items[$i]['part_number'] == $items[$i+1]['part_number']){
      unset($items[$i+1]);
      $items = array_values($items);
    }
   }
What am I doing wrong here?