Re: Unique items in an array

From: Date: Tue, 13 Dec 2011 22:09:20 +0000
Subject: Re: Unique items in an array
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-315998@lists.php.net to get a copy of this message
Marc Guay wrote:
If the contact_id is the primary key, you could also use that as array index, which would automatically filter duplicates.
Thanks for this, it's so obvious I didn't see it. I was adding items to the array with $array[] = $contact when I could have just as easily used $array[$contact['id']] = $contact;
The other question might be where are you getting the information from ;) I filter the data in the database before loading the array ... -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php

« previous php.general (#315998) next »