richiejones24 Posted February 29, 2012 Share Posted February 29, 2012 I need to double a number each loop but cant find a way to do it, so eg, 500, 1000,2000,4000 ect Link to comment Share on other sites More sharing options...
sunfighter Posted February 29, 2012 Share Posted February 29, 2012 <?php $number = 3; for($i = 0; $i < 50; $i++) { $number = 2 * $number; echo $number . '<br />'; } ?> Link to comment Share on other sites More sharing options...
Zane Posted February 29, 2012 Share Posted February 29, 2012 There's also a multiplication assignment operator.. *= so you can easily just say $number *= 2; Link to comment Share on other sites More sharing options...
Recommended Posts