PHP头条
热点:

www字典优化脚本


<?php

error_reporting(0);

echo"\n"."输入要整理的字典:"."\n";

$dic=trim(fgets(STDIN));

 

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

*字典优化工具lostwolf

* 去除字典重复 在每段数据前加斜杠并去除多余斜杠

*

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

 

 

 

 

 

$file=file($dic);

 

$array=preg_replace('/($\s*$)|(^\s*^)/m','',$file); //消除空行

 

foreach ($arrayas$key=>$r){

       

        $array[$key]=trim("/$r"); //添加斜杠 并去除空白字符

      

}

 

$new_array=preg_replace('#^([/]*)#','/',$array); //将开头多个斜杠替换成一个

 

$new_array1=array_values(array_unique($new_array));//消除重复行

 

if(file_put_contents('new_file.txt',join("\r\n",$new_array1))){

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

        echo"\n"."整理完毕!"."\r\n" ;

        echo"生成的字典文件为:"."\r\n";

        echodirname(__FILE__).DIRECTORY_SEPARATOR."new_file.txt"."\r\n";

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

}

 

else{  

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

        echo"错误!"."\r\n";

        echo"找不到文件!请检查是否存在该字典!"."\r\n";

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

}

 

 

?>

www.phpzy.comtrue/phprm/19823.htmlTechArticlewww字典优化脚本 ?php error_reporting(0); echo\n.输入要整理的字典:.\n; $dic=trim(fgets(STDIN)); /*************************************** *字典优化工具lostwolf * 去除字典重复 在每段数据前加斜杠并去除多余斜...

相关文章

    暂无相关文章

PHP之友评论

今天推荐