aebstract Posted October 9, 2008 Share Posted October 9, 2008 I know that 'array_unique' will give me an array taking out duplicates, is there any way I can create an array and ONLY display duplicates? Let's say I have an array with like 6000 items and 10 items are duplicates, I need to display just the 10 items. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted October 9, 2008 Share Posted October 9, 2008 Something like this: <?php $array = array(1,2,3,3,4,5,5); $unique = array_unique($array); $duplicates = array_diff_assoc($array,$unique); print_r($duplicates); ?> Quote Link to comment Share on other sites More sharing options...
thebadbad Posted October 9, 2008 Share Posted October 9, 2008 And if the duplicates appear more than twice in the array, just run another array_unique() on $duplicates. Edit: How obvious is that.. LOL Quote Link to comment Share on other sites More sharing options...
aebstract Posted October 9, 2008 Author Share Posted October 9, 2008 For what I am doing it won't matter if they are there more than twice or not, just need to know which ones do have dupes. Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.