www dictionary optimization Script _php Tutorial

Source: Internet
Author: User

error_reporting (0);

echo "\ n". " Enter the dictionary you want to organize: "." \ n ";

$dic =trim (fgets (STDIN));

/***************************************

* Dictionary Optimizer tool Lostwolf

* Remove the dictionary and repeat the slash before each piece of data and remove the extra slash

*

* *************************************/

$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 the first multiple slashes with a

$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". " Finishing up! "." \ r \ n ";

echo "Generated dictionary file for:". " \ r \ n ";

Echodirname (__file__). Directory_separator. " New_file.txt "." \ r \ n ";

echo "------------------------------------------". " \ r \ n ";

}

else{

echo "------------------------------------------". " \ r \ n ";

echo "Error!". " \ r \ n ";

echo "Can't find the file!" Please check if the dictionary exists! "." \ r \ n ";

echo "------------------------------------------". " \ r \ n ";

}

?>

http://www.bkjia.com/PHPjc/478532.html www.bkjia.com true http://www.bkjia.com/PHPjc/478532.html techarticle ? PHP error_reporting (0); echo\n. Enter the dictionary to be collated:. \ n; $dic =trim (Fgets (STDIN));/************************************** * * Dictionary Optimizer tool Lostwolf * Remove dictionary repetition in each ...

  • 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.