Www dictionary optimization script _ PHP Tutorial

Source: Internet
Author: User
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...

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.