Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
02-28-2013, 02:33 PM #1
- Join Date
- Apr 2010
- Thanked 0 Times in 0 Posts
How do you find ONLY unique strings in an array?
I have a list of 4000 web addresses. I need to extract all the web addresses that only occur once. Any that are in the list twice or more I don't want to know about.
How do you extract unique strings?
02-28-2013, 02:41 PM #2
The above example will output:PHP Code:
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
[a] => green
 => red
 => blue
There are 10 types of people on CodingForums,
Those who understand Binary and those who dont.
Get Cloud Hosting now from only£59 / month
03-01-2013, 03:46 PM #3
- Join Date
- Jan 2010
- Behind the Wall
- Thanked 357 Times in 353 Posts
@arctic: I think he meant not to exclude duplicate values, but to find values that that are present once and only once.
array_count_values() (and array_filter()) should be what you’ll need.
The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.André Behrens, NY Times Software Developer