I needed to increment the for loop by 7 by 7 and used the $x + 7
method as below. However, it didn't work.
for ($x = 1; $x <= 31; $x + 7) {
echo $x ."\n";
}
I solved the problem by redefining the variable as below but I am still wondering why the first method is not working.
for ($x = 1; $x <= 31; $x += 7) {
echo $x ."\n";
}
I usually use the $x++
method to increase the value. Why is $x + 7
different?
You can try: https://glot.io/snippets/g16a4it4il