简体   繁体   English

如何进行循环跳转4个步骤

[英]How to make for loop jump 4 steps

I want to make a for loop in php that goes like this 我想在php中进行这样的for循环

for($x=1; $x<=100; $x+4)

so it the outprint will be like this 1 4 8 12 etc 所以它的输出像这样1 4 8 12等

this code is not working, thats why im asking for help :) 此代码无法正常工作,这就是为什么即时消息寻求帮助的原因:)

for($x=1; $x<=100;$x+=4)

将您的最后一个expr更改为$x+=4代码的问题是$ x没有被递增。

If you want it to increment in terms of 1 4 8 12 ... you could try this code which is a little bit unconventional since you want to include when $x=1 如果您希望它以1 4 8 12的增量递增,您可以尝试以下代码,因为您想在$ x = 1时包含它,所以这有点不常规

for($x=1;$x<100;$x++) {
     if($x %4 != 0 && $x != 1) continue;
     else enter code here
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM