逐行删除文件中的内容-PHP源码
php代码
function delline($file)
{
$fp = fopen($file,"r");
$tmp = tempnam("./","temp0");
$tmp_fp = fopen($tmp,"w");
$i=0;
while(!feof($fp)){
$line = fgets($fp);
if($i!=0){
fputs($tmp_fp,$line);
}
$i++;
}
fclose($fp);
fclose($tmp_fp);
rename($tmp,$file);
}
/php/35963.htmlwww.phpzy.comtrue/php/35963.htmlTechArticle逐行删除文件中的内容-PHP源码 php代码 function delline($file){$fp = fopen($file,"r");$tmp = tempnam("./","temp0");$tmp_fp = fopen($tmp,"w");$i=0;while(!feof($fp)){$line = fgets($fp);if($i!=0){fputs($tmp_fp,$line);}$i++;}fclose(...
PHP之友评论