PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
mikeashfield
Forum Contributor
Posts: 159 Joined: Sat Oct 22, 2011 10:50 am
Post
by mikeashfield » Wed Nov 09, 2011 4:57 pm
Code: Select all
<?php
$counter=1;
while ($counter =< 20) {
echo $counter . '/n';
$counter++;
}
?>
Very elementary I know, but if anyone could help, that'd be great.
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Wed Nov 09, 2011 5:15 pm
You have =< when you want <=
You have '/n' when you want "\n"
mikeashfield
Forum Contributor
Posts: 159 Joined: Sat Oct 22, 2011 10:50 am
Post
by mikeashfield » Wed Nov 09, 2011 5:16 pm
Really? Who would have thought they were any different. Thanks for the heads up anyway, works a charm now.
twinedev
Forum Regular
Posts: 984 Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio
Post
by twinedev » Wed Nov 09, 2011 8:04 pm
Some languages don't care if you do =< or <=, PHP does
Another way of doing it:
Code: Select all
for($counter=1;$counter<=20;$counter++) {
echo $counter,"\n";
}