Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我需要它在第一个循环上运行,然后在每个第三个循环上运行
if ($k % 3 || $k==1 ) { echo '<div class="modcontainer">'; }
对我来说似乎很简单,但我不了解模数
Modulus 返回余数,而不是布尔值。
此代码将解析true为1, 3, 6, 9, ...
true
1, 3, 6, 9, ...
if (($k % 3 == 0) || $k==1 ) { echo '<div class="modcontainer">'; }
此代码将解析true为1, 4, 7, 10, ...
1, 4, 7, 10, ...
if ($k % 3 == 1) { echo '<div class="modcontainer">'; }