我正在开发一种工具来将一些数据从数据库导出到文本文件。代码如下:
$query3=mysql_query("SELECT * FROM records WHERE domain_id=".$domainID." AND type='NS' ORDER BY id ASC, name ASC");
while($result3 = mysql_fetch_array($query3))
{
$type=$result3['type'];
$content=$result3['content'];
$result = $result3['name'];
$length = strlen(".".$domainNAME);
$string = substr($result, 0, $length*(-1));
fwrite($fh,$string." IN NS ".$content."\n");
}
所以输出文本文件之一是这样的:
IN NS ns1.example.net.
team.example.net. IN NS ns1.example.net.
team.example.net. IN NS ns2.example.net.
teamex01.example.net. IN NS ns1.example.net.
teamex01.example.net. IN NS ns2.example.net.
dev.example.net. IN NS ns1.example.net.
dev.example.net. IN NS ns2.example.net.
我想像这样输出文件:
IN NS ns1.example.net.
team.example.net. IN NS ns1.example.net.
team.example.net. IN NS ns2.example.net.
teamex01.example.net. IN NS ns1.example.net.
teamex01.example.net. IN NS ns2.example.net.
dev.example.net. IN NS ns1.example.net.
dev.example.net. IN NS ns2.example.net.
我想按列排列。IN NS 记录应排列在一列中。有没有办法整理文件?
谢谢!