<? Php
Error_reporting (0 );
@ Ini_set ('memory _ limit ','-1 ');
Set_time_limit (0 );
Echo "text deduplication tool". "\ r \ n ";
Echo "\ n". "Enter the file to be sorted:". "\ n ";
$ Dic = trim (fgets (STDIN ));
/* While (! Feof ($ dic )){
$ File [] = stream_get_line ($ fp, 65535, "\ r \ n ");
}
*/
$ File = file ($ dic );
$ Array = preg_replace ('/($ \ s * $) | (^ \ s * ^)/m', '', $ file); // clear empty rows
$ New_array = array_values (array_unique ($ array); // eliminate duplicate rows
$ New_filename = "new _". basename ($ dic );
If (file_put_contents ("$ new_filename", join ("\ r \ n", $ new_array ))){
$ Num = count ($ file );
$ New_num = count ($ new_array );
$ Counts = $ num-$ new_num;
$ Files = dirname (_ FILE _). DIRECTORY_SEPARATOR. $ new_filename;
Echo <INFO
+ ---------------------------------------------- +
| [+] Repeated removal is completed! Www.2cto.com |
| [+] The sorted file is: $ files |
| [+] Number of original dictionaries: $ num |
| [+]: $ New_num |
| [+] Replaces $ counts rows. |
+ ---------------------------------------------- +
INFO;
}
Else {
Echo "----------------------------------------". "\ r \ n ";
Echo "[*] error! "." \ R \ n ";
Echo "[*] File not found! Check whether the input path exists! "." \ R \ n ";
Echo "----------------------------------------". "\ r \ n ";
Exit ();
}
?>