Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialadam miller
9,053 PointsCreate a FOR loop that displays each number from 1 to 100. Make sure that you DO NOT show 0 and you DO show 100.
this is my code :
for( $i = 1 ; $i <= 100 ; $i++){ echo[$i] . "<br /> \n" ; }
I keep receiving a BUMMER that states to make sure I end on 100.
4 Answers
Rob R
14,637 PointsHi Adam,
Since $i isn't an array, you can echo out $i without the brackets:
for( $i = 1 ; $i <= 100 ; $i++){ echo $i . "<br /> \n" ; }
Hope that helps!
Flávia Souza
3,049 PointsEven though they say "Make sure that you DO NOT show 0 and you DO show 100.", that´s the right answer:
for ($i = 1; $i <= 100; $i++){
echo $i . "<br/>\n";
}
Joy Manuel
6,464 PointsThis worked! And it's a simple format. Can't wait till it makes sense to me. :)
Mohammed Bashiru
Courses Plus Student 4,816 PointsTry this
for ($i = 1; $i < 101; ++$i ){ echo $i . "\n";
if(isset($facts[$i])){ echo $facts[$i]; } echo "<br />\n"; }
Tafadzwa Bara
1,175 Pointsi keep on getting PHP Parse error: syntax error, unexpected 'for' (T_FOR), expecting ')' //add your loop below this line for ($i = 1; $i<= 100; i++){ echo $i . "<br />"; }
sefaxu Meter
Courses Plus Student 277 Pointsfor ( $i = 1 ; $i <= 100 ; ++$i ){ echo $i . "<br/><\n>";