& Lt ;? // When writing a file, use | to separate each record. | used to separate fields in the record. // If Record 1 is expressed as & #36; str1 & #36; name. |. & amp; #36; pass. |. & amp; #36; title. |. & amp; #36; message. |. ......... // Connect to record 1 and record 2, & amp; #36; str & amp; #36; str1 // When writing a file, use "|" to separate each record. "|" is used to separate fields in the record.
// If Record 1 is $ str1 = $ name. "| ". $ pass. "| ". $ title. "| ". $ message. "| ". .........
// Connect to record 1 and record 2, $ str = $ str1. "|". $ str2. "||| ..........
// The Last generated file is as follows:
// Apsara Fox | 450948643 | this is the topic | this is the message content | 1 | Apsara Fox | 450948643 | this is the topic | this is the message content | 2 | | Apsara Fox | 450948643 | this is the topic | 3 | Apsara Fox | 450948643 | this is the topic | this is the message content | 4 | | Apsara Fox | 450948643 | this is the topic | this is the message content | 5 | Apsara Fox | 450948643 | this is the topic | this is the message content | 6 | | Apsara Fox | 450948643 | this is the topic | this is the message content | 7 | Apsara Fox | 450948643 | this is the topic | this is the message content | 8 | | Apsara Fox | 450948643 | this is the topic | 9 | Apsara Fox | 450948643 | this is the topic | this is the message content | 10 | | Apsara Fox | 450948643 | this is the topic | this is the message content | 11 | Apsara Fox | 450948643 | this is the topic | this is the message content | 12 | | Apsara Fox | 450948643 | this is the topic | this is the message content | 13 | Apsara Fox | 450948643 | this is the topic | this is the message content | 14 | | Apsara Fox | 450948643 | this is the topic | 15 | Apsara Fox | 450948643 | this is the topic | this is the message content | 16 | | Apsara Fox | 450948643 | this is the topic | this is the message content | 17 | Apsara Fox | 450948643 | this is the topic | this is the message content | 18 | | Apsara Fox | 450948643 | this is the topic | 19 | Apsara Fox | 450948643 | this is the topic | this is the message content | 20 | | Apsara Fox | 450948643 | this is the topic | 21 | Apsara Fox | 450948643 | this is the topic | this is the message content | 22 | | Apsara Fox | 450948643 | this is the topic | this is the message content | 23 |
// Start to fetch the data in the file. the program list is as follows:
$ End = "|"; // record delimiter, depending on the symbol used to write the file
$ Mid = "|"; // field separator, same as above
$ Temp = file ("messageboard.info"); // read the file content into an array
$ Temp = join ("", $ temp); // Convert the read array into a string
$ Mess = explode ($ end, $ temp); // split the output record
$ Num = count ($ mess); // calculates the number of elements in the split string array, that is, the number of records.
If (! $ Dpage) $ dpage = 1; // stores the current page number
$ Row = 15; // The number of rows you want to display on each page
If ($ num/$ row = floor ($ num/$ row) $ page = $ num/$ row; // check whether an integer can be obtained. you can get an integer.
Else if ($ num/$ row> = floor ($ num/$ row) $ page = floor ($ num/$ row) + 1; // if the total number of items except the number of items on each page is greater than the number of items on each page, add one after the sum.
Else if ($ num/$ row <= floor ($ num/$ row) $ page = floor ($ num/$ row); // if it is smaller than the integer, get the integer
$ Minnum = ($ dpage-1) * $ row; // records are retrieved from this number of current pages
$ Maxnum = $ row * $ dpage; // maximum number of records to be retrieved on the current page
For ($ I = $ minnum; $ I <$ maxnum; $ I ++)
{
$ Message = explode ($ mid, $ mess [$ I]); // splits fields in the record
$ Num1 = count ($ message); // calculates the number of elements in the array to control loops.
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