1
我的代码中存在一个foreach循环,任务的进度取决于该循环。现在,我无法找到foreach循环中正在进行的循环。最终,我无法追踪进展。在foreach中的每个循环之后调用一个函数?
有没有比包含递增变量和检查它是否跨越n个循环更好的方法?
总之:无论如何改善以下功能?
例子:
<?php
$counter = 1;
$theN = 100;
foreach($allLoops as $thisLoop) {
/*
The code to perform the "task"
*/
if($counter%$theN == 0) {
theFunction();
}
$counter++;
}
你能举个例子吗? –
@Daniel添加了它。 – kapeels