Remove Duplicates

Hi,

I have a .txt file with about 2,000 mobile numbers on it. There are at least 50 duplicate numbers in there. I also have made a page to add in more numbers, and below that I’ve tried to put a button that will clear the txt file of all duplicates, but it does not work. Please see my code below:

<?php $numbers = $_REQUEST['numbers']; $file = "../smsm.txt"; $fh = fopen($file,'a') or die ("Can't Save Number."); fwrite($fh, $numbers); fclose($fh); ///////////////////////////////////////////// $clean = $_REQUEST['clean']; $conf = "1"; if($clean == $conf) { $filename = "../smsm.txt"; $list = file($filename); // Remove duplicates $list = array_unique($list); // Write back to file file_put_contents($filename, implode('', $list)); } ?> RISE Productions | SMS


<>



Clean database of duplicate numbers?

Did you try to check if array of phones is unique after that line:

[php]
$list = array_unique($list);
[/php]

you can do this by:

[php]
echo ‘

’;
print_r($list);
echo ‘
’;
[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service