Use a text file to create a message board prompt (on)

Source: Internet
Author: User
The first is to ensure that text files can be read and written. before preparing to write files, all we need to do is to handle user messages! This can be done before submitting a table. we separate the obtained data items with specific symbols, for example, using the & amp; number, it is worth noting that if the submitted data contains specific characters, we only need SyntaxHighlighter. all (); first, ensure that text files can be read and written. before preparing to write files, all we need to do is to process user messages!
This can be done before submitting a table. we separate the obtained data items with specific symbols, for example, using the & sign, it is worth noting that if the submitted data contains a specific character, we have to convert it into other forms. you have your own solutions;
If we get the data, such:
$ Str = "aaaaa & bbbbb & ccccc & ddddd ";
Before writing data to a file, we add
$ Str = $ str .""

Then execute:
$ Fp = fopen ("txt/mytxt.txt", "");
Fwrite ($ fp, $ txt );
Fclose ($ fp );

In this way, the data we write is located at the end of the file.
How can we make the latest messages appear at the top of the message board?
With the above data processing, it is easy to handle,
$ Date = file ("txt/mytxt.txt ");
$ N = count ($ date );
For ($ I = $ n; $ I> 0; $ I --){
$ Str = explode ("&", $ date [$ I])
.
// Outputs the $ str array.
.
}

In this way, the newly inserted messages are kept in the first place.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.