Simple text duplication Removal

Source: Internet
Author: User

 

<? Php

Error_reporting (0 );

Echo "\ n". "Enter the file to be sorted:". "\ n ";

$ Dic = trim (fgets (STDIN ));

$ 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); www.2cto.com

 

If (file_put_contents ("$ new_filename", join ("\ r \ n", $ new_array ))){

Echo "----------------------------------------". "\ r \ n ";

Echo "\ n". "repeated removal is completed! "." \ R \ n ";

Echo "the file after deduplication is:". "\ r \ n ";

Echo dirname (_ FILE _). DIRECTORY_SEPARATOR. "$ new_filename". "\ r \ n ";

Echo "----------------------------------------". "\ r \ n ";

}

 

Else {

Echo "----------------------------------------". "\ r \ n ";

Echo "error! "." \ R \ n ";

Echo "file not found! Check whether the input path exists! "." \ R \ n ";

Echo "----------------------------------------". "\ r \ n ";

Exit ();

}

 

 

?>

 

From http://hi.baidu.com/nginxshel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.