Can i use divide in loop for PHP ?
I write code like that but not work.
<?PHP
for ($k=100;$k>2;$k/2)
{echo $k;}
?>
That should be $k = $k / 2
, or $k /= 2
.
As pointed out in the comments, you could also use a bit shift operation $k >>= 1
.
Try with:
for ($k=100;$k>2;$k = $k/2) {
echo $k;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With