error_reporting(0);
echo"n"."Enter the dictionary to be organized:"."n";
$dic=trim(fgets(STDIN));
/***************************************
*Dictionary optimization tool lostwolf
* Remove dictionary duplication. Add a slash before each piece of data and remove excess slashes
*
**************************************/
$file=file($dic);
$array=preg_replace('/($s*$)|(^s*^)/m','',$file); //Eliminate blank lines
foreach ($arrayas$key=>$r){
$array[$key]=trim("/$r"); //Add slashes and remove whitespace characters
}
$new_array=preg_replace('#^([/]*)#','/',$array); //Replace multiple slashes at the beginning with one
$new_array1=array_values(array_unique($new_array));//Eliminate duplicate rows
if(file_put_contents('new_file.txt',join("rn",$new_array1))){
echo"---------------------------------------------"."rn";
echo"n"."Finished!"."rn" ;
The dictionary file generated by echo" is: "."rn";
echodirname(__FILE__).DIRECTORY_SEPARATOR."new_file.txt"."rn";
echo"------------------------------------------------"."rn";
}
else{
echo"------------------------------------------------"."rn";
echo "Error!"."rn";
echo "File not found! Please check if the dictionary exists!"."rn";
echo"------------------------------------------------"."rn";
}
?>