in reply to Re: finding the first unique element in an array
in thread finding the first unique element in an array
Without the post-increment, everything would be pushed to the unique array. The second possible problem is one of interpretation. I read the original post to mean that there would be some unique entries in a list containing duplicates and the object was to find the first one. If that interpretation is correct - then you have to wait until after going through the first array in its entirety before you can know if an item is unique or not.if (!$seen{$name1[$i]}) { should be if ( ! $seen{$name1[$i]}++ ) {
Cheers - L~R
|
|---|