我有这个代码
while($row = $rs->fetch_object()){
echo $curl->get($row->site_url, 'sitekontrol', $row->id )."";
if($row->site_url == "changed") {
sendmail($mailadress);
}
}
这发送了很多次。我想在完整的结果上发送一次。
如果您想在10个站点更改后发送结果,则必须跟踪此变量。
你可能想做这样的事情:
$changes = 0;
while($row = $rs->fetch_object() && $changes < 10){
echo $curl->get($row->site_url, 'sitekontrol', $row->id )."";
if($row->site_url == "changed") {
$changes++;
}
}
if($changes >= 10) {
sendmail($mailadress);
}
编辑:改为Federico klez Culloca的解决方案。