Heim >Backend-Entwicklung >PHP-Tutorial >php循环问题?
$writefile=" $query = $db->query("SELECT aid,softurl FROM {$pre}article_content_106");
while($rs = $db->fetch_array($query)){
$writefile.="$rs[sorturl]\r\n";
}
write_file(ROOT_PATH."data/url_txt.php",$writefile);
怎么让这个循环在读取数据,到了100条的时候 ,换两行空行,与下面的100条有分隔的作用??
计数,i=1开始,每次加1, i % 100 = 0后输出
$n = 1;
while($rs = $db->fetch_array($query)){
$writefile.="$rs[sorturl]\r\n";
$writefile .= ($n++%100)? '' : "\r\n\r\n";
}