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 Basics (Retired) PHP Conditionals & Loops PHP Loops Challenge

Jason Seabolt
Jason Seabolt
10,262 Points

There appears to be a bug in the challenge checker for php-loops-challenge in task 1.

Keeps telling me that I am looking in the wrong array and I am looking in the correct array.

index.php
<?php 
$names = array('Mike', 'Chris', 'Jane', 'Bob');
foreach ( $names as $name ) {
  echo '<ul>' . $name . '</ul>';
}
?>

2 Answers

Well, maybe not a bug, but it sure seems like one. The challenge editor doesn't like the spaces. Try this:

foreach ($names as $name) {
  echo $name;
}
Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey Jason,

It seems to be White Space issue. I've searched the documentation and didn't find anything to say that what you have is incorrect. (If anyone has docs that show otherwise, please leave the link in a comment).

If you delete the White Space before and after your parenthesis, it will pass.

Task 1 Code:

<?php 
$names = array('Mike', 'Chris', 'Jane', 'Bob');

foreach ($names as $name) {
}
?>

Task 2 code -- note it didn't ask for any tags. It just wants you to echo the names.

<?php 
$names = array('Mike', 'Chris', 'Jane', 'Bob');

foreach ($names as $name) {
  echo $name;
}
?>

Keep Coding! :dizzy: