php - Change Variable Value in While Looping -


i want know how modify variable value each time while looping.

please guide me doing wrong in below coding.

$amount = 500;  while ($amount > 0) { $a = $amount - 50; echo $a . "<br>"; } 

i receiving this:

450 450 450 450 450 450 450 450 450 

but want that:

450 400 350 300 250 200 150 100 50 

you not changing the amount in loop, hence getting result 450 form statement:

$a = $amount - 50;  

which evaluates time $a = 500 - 50 = 450

change code this:

$amount = 500;  while ($amount > 0) { $a = $amount - 50; echo $a . "<br>"; $amount  = $amount - 50;  } 

Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -