Page 1 of 1

Removing Duplicate Entrys From Array ( Best ways )

Posted: Mon Sep 12, 2005 9:14 pm
by 127.0.0.1
I am looking for some opinions to learn what is the best way to do this and why.

The script is this:

for($b = 0; $b < $a; $b ++)
{
$entrysFound = 0;

for($c = 0; $c < $a; $c++)
{
if($array[$a] == $array[$c])
{
$entrysFound ++;
}
}

if($entrysFound > 1)
{
//Out put the duplicate and the number of duplicates found
echo "<br> Duplicate ".$search." ".$entrysFound ;
}
}

There is one array but there could be duplicate entry's, without going into the deep details of why there could be lets see other peoples views on removing duplicates from an array.

It is possible to search more than 1 array element for every iteration I don't know if that's something worth while doing or not?

Posted: Mon Sep 12, 2005 10:15 pm
by Buddha443556

Posted: Mon Sep 12, 2005 10:28 pm
by feyd
please be aware we prefer php code to be posted using the

Code: Select all

forum tags. Read "How to Post Code on DevNetwork" in my signature for further details.