Re: [PHP] Unique items in an array

2011-12-21 Thread Marc Guay
Hi folks, I just wanted to add a little something to this thread as I reworked some of the code and came across an interesting tidbit. I was trying to merge many result sets which now had the table's primary key as the array key, but found that when array_merge() was done, all of the array's keys

Re: [PHP] Unique items in an array

2011-12-15 Thread Marc Guay
> Give it a try, should do what you are wanting. Hi Jim, I appreciate your dedication to this problem but it was solved 2 days ago! :) Thanks Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Unique items in an array

2011-12-15 Thread Jim Lucas
On 12/15/2011 6:24 AM, Marc Guay wrote: >> Assuming you want to make things unique based on the "contact_first_name" >> field, >> how would you decide which record to keep? The first one you run in to, the >> last one you come across, or some other criteria? > > The unique field is actually the

Re: [PHP] Unique items in an array

2011-12-15 Thread Marc Guay
> Assuming you want to make things unique based on the "contact_first_name" > field, > how would you decide which record to keep?  The first one you run in to, the > last one you come across, or some other criteria? The unique field is actually the contact_id. Marc -- PHP General Mailing List (

Re: [PHP] Unique items in an array

2011-12-14 Thread Jim Lucas
On 12/13/2011 1:15 PM, Marc Guay wrote: > Hi folks, > > Let's say that I have the following array: > > [0]=> > array(35) { > ["contact_id"]=> > string(3) "356" > ["contact_first_name"]=> > string(4) "Marc" > } > [1]=> > array(35) { > ["contact_id"]=> > string(3) "

Re: [PHP] Unique items in an array

2011-12-13 Thread Lester Caine
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[$c

Re: [PHP] Unique items in an array

2011-12-13 Thread Marc Guay
> 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']] =

Re: [PHP] Unique items in an array

2011-12-13 Thread Matijn Woudt
On Tue, Dec 13, 2011 at 10:15 PM, Marc Guay wrote: > Hi folks, > > Let's say that I have the following array: > >  [0]=> >  array(35) { >    ["contact_id"]=> >    string(3) "356" >    ["contact_first_name"]=> >    string(4) "Marc" >  } >  [1]=> >  array(35) { >    ["contact_id"]=> >    string(3) "

Re: [PHP] Unique items in an array

2011-12-13 Thread Ashley Sheridan
On Tue, 2011-12-13 at 16:15 -0500, Marc Guay wrote: > Hi folks, > > Let's say that I have the following array: > > [0]=> > array(35) { > ["contact_id"]=> > string(3) "356" > ["contact_first_name"]=> > string(4) "Marc" > } > [1]=> > array(35) { > ["contact_id"]=> >

[PHP] Unique items in an array

2011-12-13 Thread Marc Guay
Hi folks, Let's say that I have the following array: [0]=> array(35) { ["contact_id"]=> string(3) "356" ["contact_first_name"]=> string(4) "Marc" } [1]=> array(35) { ["contact_id"]=> string(3) "247" ["contact_first_name"]=> string(4) "Marc" } [2]=> a