Home > Backend Development > PHP Tutorial > PHP simply removes large text duplication_PHP tutorial

PHP simply removes large text duplication_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:48:21
Original
891 people have browsed it

error_reporting(0);
@ini_set('memory_limit','-1');
set_time_limit(0);
echo" Text duplication removal tool"."rnrn";
echo"n"."Enter the files to be sorted:"."n";
$dic=trim(fgets(STDIN));
/*while (!feof($dic)){
          $file[]=stream_get_line($fp,65535,"rn");
}
*/

$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);

if(file_put_contents("$new_filename",join("rn",$new_array))){

          $num=count($file);
         $new_num=count($new_array);
         $counts=$num-$new_num;
          $files=dirname(__FILE__).DIRECTORY_SEPARATOR.$new_filename;

echo<< +------------------------------------------------+
| [+] Duplicate removal completed! www.2cto.com |
| [+] The sorted files are: $files |
| [+] Number of original dictionaries: $num rows |
| [+] After sorting: $new_num rows |
| [+] $counts rows replaced in total |
+------------------------------------------------+
INFO;

}

else{
echo"------------------------------------------------"."rn";
echo "[*] Error!"."rnrn";
             echo "[*] File not found! Please check if the input path exists!"."rn";
echo"------------------------------------------------"."rn";
exit();
}


?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478430.htmlTechArticle?php error_reporting(0); @ini_set(memory_limit,-1); set_time_limit(0); echo remove text Repeat tool.rnrn; echon. Enter the files to be sorted:.n; $dic=trim(fgets(STDIN)); /*while...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template