Does array_unique() work for arrays of objects?

I have an array of objects I created. The objects are from a custom class I created and hold a variety of variable and variable types.

My question is does array_unique() work for arrays of objects. If not, how do I check for duplicate data?



Note: Two elements are considered equal if and only if (string) $elem1 === (string) $elem2. In words: when the string representation is the same.

Dunno if this is perfect for objects, but even if the objects themselves are compared with === it is not what you want:

On the other hand, when using the identity operator (===), object variables are identical if and only if they refer to the same instance of the same class.

Workaround (ugly): Two nested for-loops with custom compare-methods on the objects

In others words, all objects are considered equal in php versions prior to 5.2 and in php 5.2 it depends on how __toString is implemented for the given class.

Okay thanks guys. Each object does have 3 variables that would be unique as a whole to each instance of the object. I guess I’ll just throw in a quick loop to compare these 3, and if they all match then I have a duplicate.