Huhu
Hier erstmal der PHP Code:
So, nun möchte ich die variable $eintrag aber an den Anfang anstatt ans Ende der msg.txt schreiben, wie krieg ich das hin?
Hier erstmal der PHP Code:
PHP:
<?
$chat_file_ok = "msg.txt";
$chat_lenght = 7;
$max_single_msg_lenght = 512;
$max_file_size = 9999999999999999999999999999999999;
$file_size= filesize($chat_file_ok);
if ($file_size > $max_file_size) {
$lines = file($chat_file_ok);
$a = count($lines);
$u = $a - $chat_lenght;
for($i = $a; $i >= $u ;$i--){
$msg_old = $lines[$i] . $msg_old;
}
$deleted = unlink($chat_file_ok);
$fp = fopen($chat_file_ok, "a+");
$fw = fwrite($fp, $msg_old);
fclose($fp);
}
$msg = str_replace ("\n"," ", $message);
$msg = str_replace ("\n"," ", $message);
$msg = str_replace ("<", " ", $msg);
$msg = str_replace (">", " ", $msg);
$msg = stripslashes ($msg);
if ($msg != ""){
$fp = fopen($chat_file_ok, "a+");
$eintrag="<b>$was</b> von $person: $msg\n";
$fw = fwrite($fp, $eintrag);
fclose($fp);
}
$lines = file($chat_file_ok);
$a = count($lines);
$u = $a - $chat_lenght;
for($i = $a; $i >= $u ;$i--){
}
?>
So, nun möchte ich die variable $eintrag aber an den Anfang anstatt ans Ende der msg.txt schreiben, wie krieg ich das hin?