/**
* @param string $path 文件夹路径
*/
function handle( string $path ) {
$open = opendir( $path );
$dir = [];
while (($file = readdir($open)) !== false){
$dir[] = $file;
}
closedir($open);
for ($i=2;$i<=count($dir)-1;$i++){
$str = file_get_contents( $path . '/' . $dir[$i] );
$str = preg_replace( '/\n/' , '' , $str );
$str = preg_replace( '/\r/' , '' , $str );
$str = str_replace( ' ' , '' , $str );
file_put_contents( $path . '/' . $dir[$i] , $str );
}
return 'success';
}
PHP去除文件夹下所有文件中换行、空格字符
最新推荐文章于 2024-04-23 22:47:07 发布