File_SearchReplace

File_SearchReplace --  provides functions for replacing text in files

Using

With SearchReplace, you can replace a text in as many as desired files by another.

The example replaces all occurences of "Yes" with "No" in the given $files in the directory "/mail/". If a line in a file starts with one of the chars in $ignoreline, possible matches will be ignored.

You can do a new search without creating a new instance of the class.

Types of search functions

File_SearchReplace supports different kinds of search functions. The type directly influence the format of the required $find-parameter

normal - default, the only type supporting the $IgnoreLines -parameter
quick - use str_replace()
preg - use preg_replace()
ereg - use ereg_replace()

To set the type, call setSearchFunction() before doSearch().

File_SearchReplace::File_SearchReplace

void File_SearchReplace::File_SearchReplace ([string $find, string $replace, string $files, mixed $directories, boolean $include_subdir, array $ignore_lines]]])

Constructor - sets the search and replace query

Parameter

File_SearchReplace::getNumOccurences

integer File_SearchReplace::getNumOccurences ()

Accessor to return the number of occurences found.

Returns

File_SearchReplace::doSearch

void File_SearchReplace::doSearch ()

This starts the search/replace off. Call this to do the search. First do whatever files are specified, and/or if directories are specified do those too.

File_SearchReplace::setFind

void File_SearchReplace::setFind (string $find)

Accessor for setting find variable.

Parameter

File_SearchReplace::setReplace

void File_SearchReplace::setReplace (string $replace)

Accessor for setting replace variable.

Parameter

File_SearchReplace::setFiles

void File_SearchReplace::setFiles (array $files)

Accessor for setting files variable.

Parameter

File_SearchReplace::setDirectories

void File_SearchReplace::setDirectories (array $directories)

Accessor for setting directories variable.

Parameter

File_SearchReplace::setIncludeSubdir

void File_SearchReplace::setIncludeSubdir (integer $include_subdir)

Accessor for setting include_subdir variable.

Parameter

File_SearchReplace::setIgnoreLines

void File_SearchReplace::setIgnoreLines (array $ignore_lines)

Accessor for setting ignore_lines variable.

Parameter

File_SearchReplace::setSearchFunction

void File_SearchReplace::setSearchFunction (array $search_function)

Function to determine which search function is used.

Parameter