This article mainly introduces the data submitted by php to generate the txt file, which is of reference value. if you need it, you can refer to a total of two files, the specific link to the database is directly removed. the front-end is the submitted text part, one line, after the submission, another program file is processed, and then the corresponding txt file is generated according to the submitted file name, and add data to the txt file. before using the file, you must create a new test file in the root directory.
The front-end form file is as follows (saved as dcwz. php ):
<? Phperror_reporting (0); // require_once (".. /config. php "); // require_once (".. /admin/ly_check.php "); // $ SQL =" select * from leibie "; // $ rs = mysql_query ($ SQL);?>
Untitled Document
The processing program for generating txt files is as follows (saved as dcwj_cl.php ):
<? Php $ biaoti_cl = explode ("\ n", $ biaoti); $ biaoti_num = count ($ biaoti_cl); $ file_type = "txt"; for ($ I = 0; $ I <$ biaoti_num; $ I ++) {$ file_name = mb_convert_encoding ($ biaoti_cl [$ I], 'gbk', "UTF-8 "); $ data [] = array ("tom", "boy", 20); $ dir = dirname (_ FILE __). "\ text \"; $ string = ""; foreach ($ data as $ k => $ v) {foreach ($ v as $ vstr) {$ string. = mb_convert_encoding ($ vstr, 'gbk', "UTF-8") ;}}$ string. = "\ r \ n"; $ filedir = $ dir. trim ($ file_name ). ". ". $ file_type; $ fileurl = str_replace ('','', $ filedir); $ fp = fopen ($ fileurl, "a +"); echo 'create '. $ fileurl.'
'; Fwrite ($ fp, $ string); fclose ($ fp) ;}?>
The above is all the content of this article. I hope it will help you learn php programming.