Q:

php file put contents reverse

Ok sorry if its a stupid question im a begginer. 
Im making a small shoutbox just for practise. 
It inserts the shout infos in a txt file. 
My problem is that, it lists the text from top to bottom, and i would like to do this reversed. 
if(isset($_POST['submit'])) {
    $text = $_POST['text'];
        if(!empty($text)) {
        $text = $_POST['text'];
        $name = $_POST['name'];
        $time = date("H:i");            
        $content = 
        "<div class='text'><em>" .  $time . " </em> 
        <span class='c11'><b>" . " <a href='userinfo_php_willbe_here.php' target='_blank'>" .  htmlspecialchars($name) . " </a>" . ": </span></b> 
        " .   htmlspecialchars($text) . "  
        </div>\n";
        file_put_contents($file, $content, FILE_APPEND | LOCK_EX);
    }
}

here is my code. 
i was googleing around with not much luck maybe i wasnt looking hard enough. 
could please someone give me a hint? 
thank you

A:

No way to do so with one function call.  You need to read the content from your target file, prepend the data in php and rewrite the whole file (see file_get_contents). 
$fileContent = file_get_contents($file);
$fileContent = $content .  $fileContent;
file_put_contents($file, $fileContent, LOCK_EX);

