代码如下:
function tree(&$arr_file, $directory, $dir_name=''){
$mydir = dir($directory);
while($file = $mydir->read()){
if((is_dir("$directory/$file")) AND ($file != ".") AND ($file != "..")){
tree($arr_file, "$directory/$file", "$dir_name/$file");
}else if(($file != ".") AND ($file != "..")){
$arr_file[] = "./MoBan$dir_name/$file";
}
}
$mydir->close();
}
$arr_file = array();
tree($arr_file, "./MoBan");
foreach($arr_file as $v){
$name = basename($v);
if(substr_count($name,'.html')>0){
$a = file_get_contents($v);
$b = iconv('GB2312', 'UTF-8', $a);
file_put_contents($v,$b);
}
}