Home >Backend Development >PHP Tutorial >Tips on creating a message board using text files_PHP tutorial

Tips on creating a message board using text files_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 17:24:37733browse

Managing your messages in a text file is not as convenient as in a database. Let's find a way to achieve this effect!
When outputting, we use arrays to save data, so we will easily assign a serial number to each set of data in order. By operating on this serial number, we can easily modify the data!
$date[0] is the first line in the text file. When we output, the serial number is assigned to 0.
The output has this effect:

Modify the message
We will customize the modify. php
if($id!=””){
$date=file(“txt/mytxt.txt”);
$str=explode(“&”,$ date[0])
?>

}else{
$str=$tech1.”&”. $tech2. ”&”.$tech3….
If($str!=””){
//Write the modified data back to the text file!
}
}?>

In this process, pay attention to keep the value of $id from being lost. When writing back the data, first read the value in the text into $date, and then $date[ $id]=$str;
$fp=fopen("txt/mytxt.txt","w");


fwrite($fp,$date);
fclose($fp );

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532134.htmlTechArticleManaging your messages in a text file is not as convenient as in a database. Let’s find a way to achieve this effect! When outputting, we use arrays to save data, so I...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn