> Something like this...
<?php
$handle = fopen("ip.txt");
$file_data = file($handle);
$file_data = array_unique($file_data);
fclose($handle);
$new_handle = fopen("ip_new.txt","w");
$new_file_data = implode("\n",$file_data);
fwrite($new_handle, $new_file_data);
fclose($new_handle);
?>
Many thanks - I will give yours a try. A helluva lot simpler than the
copy/pasting I did from the PHP.NET manuals. This is what I came up with
(don't laugh at how complex it is ;)
<?php
function my_array_unique($somearray)
{
$tmparr = array_unique($somearray);
$i = 0;
foreach ($tmparr as $v) {
$newarr[$i] = $v;
$i++;
}
return $newarr;
}
function remdupe ($filename, $return_max_lines = 0, $callback_func = null,
$do_rtrim = true, $buffer_size = 1024)
{
$open = fopen($filename, 'rb');
$open_data = array();
$line = 0;
while (!feof($open)) {
if ($do_rtrim) {
$open_data[$line] = rtrim(fgets($open, $buffer_size));
} else {
$open_data[$line] = fgets($open, $buffer_size);
}
if ($callback_func != null && function_exists($callback_func)) {
eval($callback_func . '($open_data[$line]);');
}
$line++;
if ($return_max_lines > 0) {
if ($line >= $return_max_lines) {
break;
}
}
}
fclose($open);
return $open_data;
}
$open = remdupe("ip_combined.txt");
$open = my_array_unique($open);
$fp = @fopen("ip.txt", "w");
$numElements = count($open);
for($counter = 0; $counter < $numElements - 1; $counter++) {
fwrite($fp, $open[$counter][0] . "\r\n");
}
fclose($fp);
?>