日期:2013-01-12  浏览次数:20689 次

这是个非常有用的程序,可以对文本文件进行特定的搜索,并以特定的文字替换指定的文字,举个例子说如果我这篇文章里有一个字全部打错了,有几十处,要一一找出来修改是件很麻烦的事,用下面这个就可以轻松搞定。--teaman.oso.com.cn
类文件 search_replace.inc
<?php


        class search_replace{

                var $find;
                var $replace;
                var $files;
                var $directories;
                var $include_subdir;
                var $ignore_lines;
                var $ignore_sep;
                var $occurences;
                var $search_function;
                var $last_error;

        //以下进行函数定义和设置
         
                function search_replace($find, $replace, $files, $directories = '', $include_subdir = 1, $ignore_lines = array()){

                        $this->find            = $find;
                        $this->replace         = $replace;
                        $this->files           = $files;
                        $this->directories     = $directories;
                        $this->include_subdir  = $include_subdir;
                        $this->ignore_lines    = $ignore_lines;

                        $this->occurences      = 0;
                        $this->search_function = 'search';
                        $this->last_error      = '';

                }

        /***************************************
 &nbs