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?
Removing Duplicate Entrys From Array ( Best ways )
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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.