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 trial

PHP PHP Arrays and Control Structures PHP Loops For Looping

Create 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
Rob R
14,637 Points

Hi 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!

Even 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";
}

This worked! And it's a simple format. Can't wait till it makes sense to me. :)

Try this

for ($i = 1; $i < 101; ++$i ){ echo $i . "\n";

if(isset($facts[$i])){ echo $facts[$i]; } echo "<br />\n"; }

i 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 />"; }

for ( $i = 1 ; $i <= 100 ; ++$i ){ echo $i . "<br/><\n>";