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

PHP Arrays and Control Structures. Challenge Task 2 of 2

I'm not sure where I'm getting it wrong!!

Nazim Mohamed
Nazim Mohamed
1,014 Points

You need to post some of your code or what you are doing for us to be able to tell you where you are going wrong.

Partson Chizema:

I'm stuck on it, too. Here's what doesn't work:

for ($i =1; $i <= 100; $i++) { echo $i . "\n"; if (isset($facts[$i])) { echo $i . $facts[$i] . "\n"; } }

The first part of this code beginning with "for", is correct. The 2nd part beginning with "if" is incorrect. Note the "if" statement is inside of the "for" loop. The results are inserted after the key 2, so the 2nd code block interrupts the 1st code block. Don't make the 2nd code block a "while" loop because it will overload the memory & crash!