I have this code, but i want in second loop a decrease of $p value. The first internal loop must be repeated three times, the second, two times and the last, one time. I am trying $p– but without success.
Any idea ? thanks
$p = 3;
for ($i = 0; $i < 3; $i++) {
for ($o = 0; $o < $p; $o++) {
echo "something";
$p--;
}
}
Move your
$p--to outside the innerforloop:Or better, just depend on the value of
$i:Or if you don’t actually use
$i: