时间:2021-07-01 10:21:17 帮助过:57人阅读
前台表单文件如下(保存为dcwz.php):
<?php error_reporting(0); //require_once("../config.php"); //require_once("../admin/ly_check.php"); //$sql="select * from leibie"; //$rs=mysql_query($sql); ?>无标题文档
生成 txt 文件的处理程序如下所示(保存为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 '创建'.$fileurl.'
'; fwrite($fp,$string); fclose($fp); } ?>
以上就是本文的全部内容,希望对大家学习php程序设计有所帮助。