Here's a little diddy, that i whiped up...havn't tested it though.
get you script that inputs the news into the file to seperate the news with a line that contains somthing like ^&.
<?PHP
$textfile = "Your/Path/to/file"; //set the path to the file here.
if ($text = @file("textfile")) //Don't display errors on file open
{
$y = 0; //set the height var. for the array.
for ($x=0; $x<count($text); $x++)
{
$tmp = $text[$x];
if ($tmp == "^&")
{
//we have a line break
$textarr[$y][$x] = $text[$x]; //we will need to have the
//line break later when
//outputing.
$y++;
}
else
{
//we have text that is still part of a new item.
$textarr[$y][$x] = $text[$x];
}
}
//Now to output the text
for ($x=count($text); $x<>0; $x--)
{
if ($textarr[$y][$x] == "^&") //we have a line brake.
{
$y--;
}
else
{
echo $textarr[$y][$x];
}
}
}
?>
Anyways, That's how i would do it, but kurifu is right
Quote:
The easiest method is just to write new data to the front of the file.. which means everytime you want to write to a file, write to a temporary file, copy the old news file the the end of the temp file, then move the temp file to the original file's place.
|
Note i havn't tested this code yet, so it might be right or wrong. Probally got some errors in it. And when your putting the news into your file only make a line brake at the top of your news text that you inputting, otherwise you'll get werid stuff happening when you output the code because of the array.
Good luck and hope my code is right...heh