8月232014
php批量修改文件内容函数
function find_all_dir( $dir,$research=array(), $replace=array()){ //找到目录下的所有文件: $dh = opendir( $dir ); while ( $file = readdir( $dh ) ) { if ( $file != "." && $file != ".." ) { $fullpath = $dir . "/" . $file; if ( !is_dir( $fullpath ) ) { $f=fopen($fullpath, 'r'); $text=fread($f, filesize($fullpath)); //对内容进行修改 $text=str_replace($research, $replace , $text); //判断结果 $result=file_put_contents($fullpath, $text); } else { find_all_dir( $fullpath ); } } } closedir( $dh ); }
发表评论
木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!