I downloaded an excellent script from www.1phpstreet.com called 'Cutting line from a file' that does just this. Since I just used it I have it handy. Here is the function (I'm also including the author's comments):
//***********************************
// Name: Cutting line from a file
// Description:This function strips a specific line of a file. If no linenumber is given, last line is stripped. by Bram Heerink
// By: PHP Code Exchange
//
//
// Inputs:None
//
// Returns:None
//
//Assumes:None
//
//Side Effects:None
//***********************************
<?php
// this function strips a specific line from a file
// if no linenumber is specified, last line is stripped
// if a line is stripped, functions returns True else false
//
// e.g.
// cutline('foo.txt'); // strip last line
// cutline('foo.txt',1); // strip first line
function cutline($filename,$line_no=-1) {
$strip_return=FALSE;
$data=file($filename);
$pipe=fopen($filename,'w');
$size=count($data);
if($line_no==-1) $skip=$size-1;
else $skip=$line_no-1;
for($line=0;$line<$size;$line++)
if($line!=$skip)
fputs($pipe,$data[$line]);
else
$strip_return=TRUE;
return $strip_return;
}
?>
Hope that helps.