Array reverse? Help<

admin

Administrator
Staff member
$f = fopen("news.txt","r");
$filename = "news.txt";
$contents = fread($f,filesize($filename));
$news = explode('<!--end-->',$contents); // make array out of messages
$output = array_reverse($news); // reverses the messages
echo($output);
fclose($f);

<!-- m --><a class="postlink" href="http://www.ryan.epherion.com">http://www.ryan.epherion.com</a><!-- m -->
I can't get the array reverse thing to work. It just says "Array" It worked fine before I put the explode and array reverse lines in there but I need them so my news posts will show in reverse order, so the newest is on top. In case it matters I am writing to the file with a+ fopen but Ive done things like this with flat files before and havnt run into this Array problem.you cant use echo on an array, it will only diplay "Array"
if you want to see the contents of the array, use print_r($output);Yeah I shoulda posted but I figured it out using a for loop.use print_r($array) to display the contents of the array and the keys.
 
Back
Top