- Impact
- 109
Hi all,
Every so often i like to remove duplicate lines from a list of raw data, if you want to do this with php, here's a simple way to do so:
Hope you find it useful, i have countless times.
-Rhett.
Every so often i like to remove duplicate lines from a list of raw data, if you want to do this with php, here's a simple way to do so:
PHP:
<?php
/*
REMOVE DUPLICATE ENTRIES
DISPLAYS UNIQUE ENTIRES
*/
$list='random something
something or other
something
something else
something
randomness
chicken
bar snacks
something
foiled butter
O.o
...confuuussseeedd.........';
$listArray=explode("\n",$list);
$nonDupeList=array();
for($i=0;$i<count($listArray);$i++)
{
if(!in_array($listArray[$i],$nonDupeList))
{
$nonDupeList[]=$listArray[$i];
echo $listArray[$i]."<br />";
}
}
?>
Hope you find it useful, i have countless times.
-Rhett.