Hi guys,
The following code is suposed to match @delete=(n)@ (Where n is a post number in a shoutbox) and then delete the line n but, the problem is it does not work, ideas anyone?
<?php
if ($Is_Admin){
if (preg_match("/@delete=(\d)@/", $_POST['Content'], $RowToDelete)){
$RowToDelete = $RowToDelete[0];
$FileName = "Shout.txt"; // The file which holds all the data.
$FileArray = file($FileName); // Open the data file as an array.
$NumLines = count($FileArray); // Count the elements in the array.
$FP = fopen($FileName, "w"); // Open the file for writing.
for($i = 0; $i < $NumLines; $i++){// Overwrite the content except the line to be deleted.
if($i != ($RowToDelete - 1)){
fwrite($FP, $FileArray[$i]);
}
fclose($FP); // Close the data file.
}
}
}
?>
Presume $Is_Admin is true and $_POST['Content'] is @delete=(A Number)@
Any ideas?
Thanks for the help,
RyanJ