Forum Moderators: coopster
AAAA
BBBB
CCCC
DDDD
#*$!#*$!XX
array_shift [us3.php.net] removes the first item, array_pop [us3.php.net] the last, array_splice [us3.php.net] to remove items within the array.
A side note, all these return the removed items, so if you want to do anything with them, you can.
$removed = array_pop($line_array);
//all of the lines
$fileArray = file($fileName);
array_pop($fileArray);
//open the file for overwriting
$handle = fopen($fileName, "w");
//now write all of the lines except the last one
//that was removed from the array
foreach($fileArray as $i){
//if this doesn't work print some error
if(!(fwrite($handle, $i."\n"))){
echo("there was some error in writing the line $i");
}//if !(fwrite)
}
fclose($handle);