Www dictionary optimization script .? Phperror_reporting (0); echon. enter the dictionary to be sorted :. n; $ dictrim (fgets (STDIN )); **************************************** dictionary optimization tool lostwolf * removes dictionary duplicates in each
Error_reporting (0 );
Echo "\ n". "enter the dictionary to be sorted:". "\ n ";
$ Dic = trim (fgets (STDIN ));
/***************************************
* Dictionary optimization tool lostwolf
* Remove dictionary duplication by adding a slash before each segment of data and removing the extra slash
*
**************************************/
$ File = file ($ dic );
$ Array = preg_replace ('/($ \ s * $) | (^ \ s * ^)/M', '', $ file); // clear empty rows
Foreach ($ arrayas $ key => $ r ){
$ Array [$ key] = trim ("/$ r"); // add a slash and remove white space characters
}
$ New_array = preg_replace ('# ^ ([/] *) #', '/', $ array); // replace multiple front slashes with one
$ New_array1 = array_values (array_unique ($ new_array); // eliminate duplicate rows
If(file_put_contents('new_file.txt ', join ("\ r \ n", $ new_array1 ))){
Echo "----------------------------------------". "\ r \ n ";
Echo "\ n". "finished! "." \ R \ n ";
Echo "the generated dictionary file is:". "\ r \ n ";
Echodirname (_ FILE _). DIRECTORY_SEPARATOR. "new_file.txt". "\ r \ n ";
Echo "----------------------------------------". "\ r \ n ";
}
Else {
Echo "----------------------------------------". "\ r \ n ";
Echo "error! "." \ R \ n ";
Echo "file not found! Check whether the dictionary exists! "." \ R \ n ";
Echo "----------------------------------------". "\ r \ n ";
}
?>
Http://www.bkjia.com/PHPjc/478532.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478532.htmlTechArticle? Php error_reporting (0); echo \ n. enter the dictionary to be sorted :. \ n; $ dic = trim (fgets (STDIN )); /*************************************** * dictionary optimization tool lostwolf * removes dictionary duplicates in every...