error_reporting(0);
@ini_set('memory_limit','-1');
set_time_limit(0);
echo" Text duplication removal tool"."rnrn";
echo"n"."Enter the files to be sorted:"."n";
$dic=trim(fgets(STDIN));
/*while (!feof($dic)){
$file[]=stream_get_line($fp,65535,"rn");
}
*/
$file=file($dic);
$array=preg_replace('/($s*$)|(^s*^)/m','',$file); //Eliminate blank lines
$new_array=array_values(array_unique($array));//Eliminate duplicate rows
$new_filename="new_".basename($dic);
if(file_put_contents("$new_filename",join("rn",$new_array))){
$num=count($file);
$new_num=count($new_array);
$counts=$num-$new_num;
$files=dirname(__FILE__).DIRECTORY_SEPARATOR.$new_filename;
echo<<
| [+] Duplicate removal completed! www.2cto.com |
| [+] The sorted files are: $files |
| [+] Number of original dictionaries: $num rows |
| [+] After sorting: $new_num rows |
| [+] $counts rows replaced in total |
+------------------------------------------------+
INFO;
}
else{
echo"------------------------------------------------"."rn";
echo "[*] Error!"."rnrn";
echo "[*] File not found! Please check if the input path exists!"."rn";
echo"------------------------------------------------"."rn";
exit();
}
?>