I'm looking to create a function that checks an array for duplicate elements, and removes those elements only if the duplicate element is the same as the previous element. Let me give you a simple example:
The following array (in this case, the array will not be multi-dimensional) is as follows:
array('apple', 'apple', 'pear', 'orange', 'banana', 'apple', 'banana');
In this case, the remove duplicate array function, would return an array with the following elements:
array('apple', 'pear', 'orange', 'banana', 'apple', 'banana');
Note that there are still "duplicates" in the array. In case case, the first and second element, were duplicates (both "apple"), with one preceding the other. That said, there are three cases of "apple" found in the first array, but only one (in this case, the second element), was removed, because it was a duplicate of the previous element in the array. Going on those rules, while there are duplicates of "banana", since it isn't a duplicate of the previous array element, it isn't removed. Any ideas on a good function for this?