Re: Unique items in an array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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) "247"
>     ["contact_first_name"]=>
>     string(4) "Marc"
>   }
>   [2]=>
>   array(35) {
>     ["contact_id"]=>
>     string(3) "356"
>     ["contact_first_name"]=>
>     string(4) "Marc"
>  }
> 
> And I would like to filter out exact duplicates, such as key 0 and key
> 2 in this example, leaving me with an array containing only unique
> entries.  How would you go about it?
> 
> Thanks for any help,
> Marc
> 

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?

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux