Home > Backend Development > PHP Tutorial > Use text files to create message board prompts (Part 2)_PHP tutorial

Use text files to create message board prompts (Part 2)_PHP tutorial

WBOY
Release: 2016-07-21 16:04:37
Original
1018 people have browsed it

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, and we assign the sequence number to 0 when outputting.
The output has this effect:

$str=explode("&",$date[0])
?>


>
< input type="text" name="tech2" value=>
>



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

Be careful not to lose the value of $id during this process. When writing back the data, first Read the value in the text into $date, then $date[$id]=$str;
$fp=fopen("txt/mytxt.txt","w");
fwrite($fp,$ date);
fclose($fp);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315929.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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template