Php simply removes large text duplicates .? Phperror_reporting (0); @ ini_set (memory_limit,-1); set_time_limit (0); echo tool for removing text duplication. rnrn; echon. enter the file to be sorted :. n; $ dictrim (fgets (STDIN); * while 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 < + ---------------------------------------------- +
| [+] 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 ();
}
?>
Http://www.bkjia.com/PHPjc/478430.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478430.htmlTechArticle? Php error_reporting (0); @ ini_set (memory_limit,-1); set_time_limit (0); echo tool for removing text duplication. \ r \ n; echo \ n. enter the file to be sorted :. \ n; $ dic = trim (fgets (STDIN);/* while...