Hi
I've done a search and found the answer using a String, but I need to use an array! So I thought I'd post and see if anyone can help.
This is my code:
$ContactDataFile = "datafile.csv";
$aCompleteData = @file ($ContactDataFile);
$aCompleteData = array_reverse($aCompleteData);
$MessageHolder = $aCompleteData[$Msg];
$aCompleteData = str_replace($MessageHolder, "", $aCompleteData);
//Open up file to write back new data
$OpenPointer = fopen($ContactDataFile, "w");
//implode the array to a string
$sAllData = implode("\n", $aCompleteData);
fwrite($OpenPointer, $sAllData);
fclose($OpenPointer);
Now this code works except for one vital problem, on the line with the str_replace, it needs to replace the string in $MessageHolder AND the following new line (\n). At the moment it leaves the new line behind!
I was thinking I could maybe use a substr function to delete the newline after the str_replace, but this isn't really the route I want to use, if it would indeed work!
Any help very much grateful
Cheers