我想知道 $count++ 递增计数器的方式是否可以在条件语句中使用?变量会保持它的新值吗?
$count = 0;
foreach ($things as $thing){
if($count++ == 1) continue;
...
}
最佳答案
http://www.php.net/manual/en/language.operators.increment.php
要回答您的问题,这是完全有效的,只需检查 if 完成后您的值是否为 2。
关于PHP:在 if 条件下使用 $count++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20999800/