PDA

View Full Version : basics!?!


tony09uk
07-05-2012, 06:24 PM
I am currently going over my basics and trying to make it second nature (without much luck :s)

I cant work out an issue with the for loop

for($r = 1; $r <=20; $r++){
echo $r . "<br/>";
}

works fine but:

for($r = 1; $r <=20; $r*2){
echo $r . "<br/>";
}

does not. Why? I assumed as I was using a mathematical operator it would work just fine.

edbr
07-06-2012, 01:46 AM
if i recall correctly it needs to be

for($r = 1; $r <=20; $r*=2){
echo $r . "<br/>";
}

tony09uk
07-11-2012, 09:50 PM
thanks. Soted it perfectly