Hi there,
I'm trying to make a simple news poster, I'm really struggling with the array_reverse though.
<?php
$title = $_POST["title"];
$newsy = $_POST["news"];
$postedbyy = $_POST["postedby"];
$date = date("l jS F Y, g:i A");
$postedby = "<h1>$title</h1><br>$newsy</font>";
$news = "<p><small><font color=\"black\">Posted by <font color=\"red\">$postedbyy</font><font color=\"black\"><br>On $date<p></font>";
$myFile = "news1.html";
$fh = fopen($myFile, 'a+') or die("can't open file");
$stringData = "$postedby\n";
fwrite($fh, $stringData);
$stringData = "$news\n";
fwrite($fh, $stringData);
fclose($fh);
echo "Your news has been posted<br><a href=\"http://shuginternational.x10hosting.com/news/news1.html\">View it here</a>";
php?>
This is what I've come up with so far and it works to post basic news, the news.html file will be an include on my page.
Obviously i'd like to use the array_reverse so new news is at the top?
I have been searching for hours and found a lot, if someone could incorporate that into my script and explain a little why they did it that would be great. Like I said, I'm not being lazy, just can't find what I want to know.
I know there's the implode option too, but I'd actually like to know how to write to the beginning of a file without overwriting information already there.
Once again, help appreciated.