The first is to ensure that the text file can read and write, before the file is ready to write, we have to do is to handle the user message!
This work can be done before the submission of the form, we will get the data are separated by a specific symbol, for example, with the &, it is worth noting that if the data submitted if there is a specific character, then we have to convert him into other forms, which you have your own way;
If we get the data shape like:
$str = "AAAAA&BBBBB&CCCCC&DDDDD";
Before we write the data to the file, we add
$str = $str. " \ r \ n "
Then execute:
$FP =fopen ("Txt/mytxt.txt", "a");
Fwrite ($fp, $txt);
Fclose ($FP);
So the data we write is at the end of the file.
How to make the latest message appear in the message board first?
The data has the above processing, it is good to run,
$date =file ("Txt/mytxt.txt");
$n =count ($date);
for ($I = $n; $I >0; $I--) {
$str =explode ("&", $date [$I])
.
Will get the output of the $STR array.
.
}
So the latest inserted message will remain in the first place.
The above introduces the local people's Daily information board with a text file to create message board tips (on), including the local leaders of the daily Information Board of the content, I hope that the PHP tutorial interested friends have some help.