for循环
for ($x = 0; $x <= 10; $x++) { echo "The number is: $x <br>"; }
对于上述for循环,输出将为
0,1,2,3,4,5,6,7,8,9,10
像这样,但我需要相差0.5->
0,0.5,1,1.5,2,2.5,3,3.5 .......
像这样我要输出谢谢
答案 0 :(得分:0)
尝试用0.5递增
for ($x = 0; $x <= 10; $x+= 0.5 ) { echo "The number is: $x <br>"; }