Hello,
This is a reply to an e-mail that you wrote on Wed, 9 Jul 2003 at 14:55,
lines prefixed by '>' were originally written by you.
> Having STFM I am wondering if anyone knows of a quick antithesis to
> array_unique? We have an array in which we need to return all
> duplicate
> values instead of the non-duplicates.=20
How about:
$array1 = array("dupe","dupe","another item");
$valuecount = array();
foreach($array1 as $value){
if(isset($valuecount[$value])){
$valuecount[$value]++;
} else {
$valuecount[$value] = 1;
}
}
$dupes = array();
foreach($valuecount as $value=>$count){
if($count>1){
array_push($dupes,$value);
}
}
// $dupes now contains all duplicate values.
There may be a quicker way of doing it though...
David.
--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/
Professional Web Development by David Nicholson
http://www.djnicholson.com/
QuizSender.com - How well do your friends actually know you?
http://www.quizsender.com/
(developed entirely in PHP)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php