error_reporting (0);
echo "\ n". " Enter the file you want to organize: "." \ n ";
$dic =trim (fgets (STDIN));
$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); Www.2cto.com
if (file_put_contents ("$new _filename", join ("\ r \ n", $new _array))) {
echo "------------------------------------------". " \ r \ n ";
echo "\ n". " Remove duplicates Complete! "." \ r \ n ";
echo "Remove duplicate files as:". " \ r \ n ";
echo dirname (__file__). Directory_separator. " $new _filename "." \ r \ n ";
echo "------------------------------------------". " \ r \ n ";
}
else{
echo "------------------------------------------". " \ r \ n ";
echo "Error!". " \ r \ n ";
echo "Can't find the file!" Please check the input path exists! "." \ r \ n ";
echo "------------------------------------------". " \ r \ n ";
Exit ();
}
?>
Excerpted from Http://hi.baidu.com/nginxshel
http://www.bkjia.com/PHPjc/478473.html www.bkjia.com true http://www.bkjia.com/PHPjc/478473.html techarticle ? PHP error_reporting (0); echo\n. Enter the file to be collated:. \ n; $dic =trim (Fgets (STDIN)); $file =file ($dic); $array =preg_replace (/( $\s*$) | (^\s*^)/M,, $file); Eliminate empty lines $new _array=a ...