Hello, i've got a simple problem i can't figure out. I've got a text file database, i need to delete lines with a certain detail.

My file looks like this:

Code:
<?php die(); ?>
a|1|September 3rd 07|1|1
a|2|September 3rd 07|2|1
a|2|September 3rd 07|2|1
a|3|September 3rd 07|3|1
and my code:

Code:
$filearray = file($commentfile);
unset($filearray[0]);

foreach($filearray as $lnum => $thisline){
$break = "|";
list($name_comm, $comment, $date, $id, $status)=explode($break,$thisline);

if($_GET['delete'] == $id){
unset($filearray[$lnum]);
}
}

$fd = fopen ($commentfile, "w");
fwrite ($fd, "<?php die(); ?>\n");

$all = count($filearray);
for($i = 1; $i < $all; $i++) {
fwrite ($fd, $filearray[$i]);
}

fclose($fd);
When the script is used to, for example delete lines with 2 in, it deletes those *and* lines with 1 in. I think this is because when the line is unset, it doesn't match the $lnum. But i'm not sure.

Thanks