Re: opposite of array_unique()?
| From: | Jason Davidson | Date: | Wed, 04 Aug 2004 19:59:35 +0000 |
| Subject: | Re: opposite of array_unique()? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-192743@lists.php.net to get a copy of this message | ||
you could loop thru the array, and using a nested loop, test each value
against all other values.. and keep ones that match in a new array.
But as mentioned, SQL would be easier.
Jason
Curt Zirzow <php-general@zirzow.dyndns.org> wrote:
>
> * Thus wrote Adam Williams:
> > for example if I have an array:
> >
> > array( [0] => 'dog', [1] => 'cat', [2] => 'rabbit',
> > [3] => 'cat')
> >
> > how do I make it just have array ( [0] => 'cat' )? i want to drop the
> > non-duplicates and trim the array to only have one of the duplicates?
>
> If you're pulling this data from a sql table, then you're better
> off having the database server do this work for you.
>
>
> Curt
> --
> First, let me assure you that this is not one of those shady pyramid schemes
> you've been hearing about. No, sir. Our model is the trapezoid!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>