Login   Register  
PHP Classes
elePHPant
Icontem

File: FileScopeReplacer/script_test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ilya Nemihin  >  File Scope Replacer  >  FileScopeReplacer/script_test.php  >  Download  
File: FileScopeReplacer/script_test.php
Role: Example script
Content type: text/plain
Description: Usage example
Class: File Scope Replacer
Find and replace data in files in directories
Author: By
Last change:
Date: 2004-01-13 21:18
Size: 992 bytes
 

Contents

Class file image Download
<?php

require_once('FileScopeReplacer.php');

$params = array();

//--------------- configuration --------------

// directory where files will be searched to replace
$params['dir'] = '.';

// set to 1 if you want to proceed also nested directories
$params['include_nested'] = 0;

// this is string of what you are looking for
$params['search_what'] = 'test';

$params['replace_to'] = '[this place have been replaced]';

// setting for filtering, set '' if no filtering,
// otherwise thi is regexp expression like: '/your_regexp/flags', 
// see http://www.php.net/manual/en/pcre.pattern.syntax.php
$params['file_name_match'] = '/^test/';  // <-- this mean beginning from 'test'


//--------------- end configuration --------------

$replacer = new FileScopeReplacer$params );
$replacer->doWork();

echo 
'Was processed '.count($replacer->processed_files).' file(s).'."\n";
foreach( 
$replacer->processed_files as $file_path ){
  echo 
$file_path."\n";
}

?>