【www.gdgbn.com--word】
$res=mysql教程_query("select k1,k2 from ".table("keywords")." ") ;
$str="
while($rs=mysql_fetch_array($res))
{
$str .="$keyword["".$rs[0].""]="".$rs[1]."";rn";
}
$str.="?>";
file_put_contents("keyword.php",$str);
echo "导出成功";
//方法二
$f=file_get_contents("w1.txt");
$f=str_replace("rn","
",$f);//替换换行符
$arr=explode("
",$f);
$str="
foreach($arr as $t)
{
$rs=explode("|",$t);
//不能包含?等特殊符号
$str .="$keyword["".str_replace("?","",$rs[0]).""]="".str_replace("?","",$rs[1])."";rn";
}
$str.="?>";
file_put_contents("keyword.php",$str);
echo "导出成功";
//conn.php文件
$conn=mysql_connect($mysql_host,$mysql_user,$mysql_password) or die("连接服务器出错");
mysql_select_db($mysql_db) or die("选择数据库出错");
mysql_query("set names "gbk"");
function table($t)
{
global $mysql_table_prefix;
return $mysql_table_prefix.$t;
}
?>