展开全部
<?php
$handle = @fopen("/tmp/inputfile.txt", "r");
$contents = "";
if ($handle) {
while (($buffer = fgets($handle, 4096)) !== false) {
if(!preg_match("/\d/",$buffer))
{
$contents.=$buffer;
}
}
if (!feof($handle)) {
echo "Error: unexpected fgets() fail\n";
}
fclose($handle);
}
echo $contents;
//如果要写回文件需要重新打开文件
$handle = @fopen("/tmp/inputfile.txt", "w");//将文件大小截为0,即删除内容
fwrite($handle,$contents);
fclose($handle);
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询