Use a text file to create a message board prompt (below)
Source: Internet
Author: User
Managing your messages in text files is not as convenient as in the database. next we will try to achieve this effect! When outputting data, we use arrays to store data. Therefore, we can easily assign an sequence number to each group of data in order and operate on the sequence number, we can easily modify the data! & #36; dSyntaxHighlighter. all (); managing your messages in text files is not as convenient as in the database. next we will try to achieve this effect!
When outputting data, we use arrays to store data. Therefore, we can easily assign an sequence number to each group of data in order and operate on the sequence number, we can easily modify the data!
$ Date [0] is the first line in the text file. when we output the data, the allocation sequence number is 0.
The output has the following effect:
(As the mainstream development language )? Id = 0'> modify message
We will then customize modify. php (as the mainstream development language)
If ($ id! = ""){
$ Date = file ("txt/mytxt.txt ");
$ Str = explode ("&", $ date [0])
?>
} Else {
$ Str = $ tech1. "&". $ tech2. "&". $ tech3 ....
If ($ str! = ""){
// Write the modified data back to a text file!
}
}?>
In this process, note that the value of $ id is not lost. when writing back data, read the value in the text into $ date, and then $ date [$ id] = $ str;
$ Fp = fopen ("txt/mytxt.txt", "w ");
Fwrite ($ fp, $ date );
Fclose ($ fp );
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.