Пора уже на php5 переходить
Вообщем мини класс накатал, в друг кому пригодиться
Код:
<?php
class replaceFiles {
private $array_file;
private $ereg = "/.+/";
function __construct( $path ) {
$this->path = $path;
}
public function ereg( $ereg ) {
$this->ereg = $ereg;
}
public function replace( $search, $replace ) {
$dir = dir( $this->path );
while( false !== ( $file = $dir->read() ) ) {
if( $file != "." and $file != ".." and !is_dir( $file ) ) {
if( $this->path != "." or $file != basename( __FILE__ ) ) {
if( preg_match( $this->ereg, $file ) ) {
file_put_contents( "{$this->path}/$file", preg_replace( $search, $replace,
file_get_contents( "{$this->path}/$file" ) ) );
}
}
}
}
$dir->close();
}
}
$files = new replaceFiles( "." );
$files->ereg( "/.txt$/" );
$files->replace( "/123/", "456" );
?>