RE: [PHP] removing all duplicate values from an array

From: Kevin Stone (kevin_at_helpelf.com)
Date: 10/30/03


To: <php-general@lists.php.net>
Date: Thu, 30 Oct 2003 11:23:48 -0700

Or... you could use array_count_values() and loop through the array it
produces to find out how many of each duplicate value exists in the
original array.

http://www.php.net/manual/en/function.array-count-values.php

Kevin

-----Original Message-----
From: Allowee [mailto:Vincent@GeversXL.nl]
Sent: Thursday, October 30, 2003 10:28 AM
To: php-general@lists.php.net
Subject: [PHP] removing all duplicate values from an array

Hi,

I'm looking for a function that does almost the same as array_unique()

But it must also delete the other duplicate entry.

sample to explain:

array(
'a' => 'one',
'b' => 'one',
'c' => 'zero',
'd' => 'two'
);

I now want the result to be:

array(
'c' => 'zero',
'd' => 'two'
);

This way I will be able to do an array_diff and then see all the
duplicate
entries listed.

this is to find dup. ip address for a hosting system, displaying both
accounts will make it easy to trace the amount of accounts 1
ip curruntly has.

Anybody know how to do this?

Thanks,
Allowee

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


Relevant Pages

  • Re: Repost (Comparing two ranges)
    ... I was on the right track assuming a countif type function instead of ... The result does not take into account the duplicate ... Is there a way to compare two ranges where you can create an array ... Remember I want to put it into a SUMPRODUCT function. ...
    (microsoft.public.excel.worksheet.functions)
  • RE: Speed up Array Transfer to Dictionary
    ... of comparisons every time you have a known duplicate. ... array with themselves. ... array in the first place as a dictionary cannot have duplicate keys. ... dupe = dupe + 1 ...
    (microsoft.public.excel.programming)
  • Re: Repost (Comparing two ranges)
    ... range A2:A6 to drive data validation dropdown boxes in the range B9:D11. ... The result does not take into account the duplicate ... Is there a way to compare two ranges where you can create an array ... Remember I want to put it into a SUMPRODUCT function. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Repost (Comparing two ranges)
    ... range A2:A6 to drive data validation dropdown boxes in the range B9:D11. ... The result does not take into account the duplicate ... Is there a way to compare two ranges where you can create an array ... Remember I want to put it into a SUMPRODUCT function. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Repost (Comparing two ranges)
    ... The result does not take into account the duplicate ... Is there a way to compare two ranges where you can create an array ... Remember I want to put it into a SUMPRODUCT function. ... to create the boolean data above? ...
    (microsoft.public.excel.worksheet.functions)