$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);
?>