以下方法中文件路径的扩展格式需要.ini的,当然也可以修改php配置文件支持更多的扩展名。

class FileUtil
{
    public static function delRepeatRow($filePath)
    {

        $fileArr = file($filePath);
        $newFile = "整理过的文件:\n 时间:" . date('Y-m-d H:i:s') . "\n-------------------------------------------------------------------\n";
        foreach(array_unique($fileArr) as $fa){
            if(!empty($fa)){
                if((substr(trim($fa),0,8))!='Revision'){
                    $newFile.=trim($fa,' ');
                }
            }
        }
        $fp = @fopen($filePath, "w"); //以写的方式打开文件
        @fputs($fp, $newFile);
        @fclose($fp);
    }

}

 调用方式:FileUtil::delRepeatRow($filePath);

 强调:$filePath为文件的可访问路径,并且为.ini格式。

 例子:FileUtil::delRepeatRow("D:\\xampp\\htdocs\\kBase\\protected\\components\\2012-07-10.ini");

相关文章:

  • 2021-05-11
  • 2022-12-23
  • 2021-07-30
  • 2021-08-22
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-01
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
相关资源
相似解决方案