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

Aleksander Z. Cehajic
Aleksander Z. Cehajic
3,111 Points

Bummer?

when I preview code everything looks good, stil I can not get further to the next step. :(

index.php
<?php 

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

foreach($names as $name){
  echo "<li>" . $name . "</li>";             
}

?>

4 Answers

Mayur Pande
PLUS
Mayur Pande
Courses Plus Student 11,711 Points

Hi I got this to work;

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

foreach ($names as $name){
  echo "$name <br />";
}

?>

This works as it echos one name, and then skips to the new line. Hope this helps.

Aleksander Z. Cehajic
Aleksander Z. Cehajic
3,111 Points

thx . Yes, you are right. When I removed list structure it worked. thx a again.

on thing to remember when doing the challenges is that they are very rigid. The second part of the challenge just wants you to echo the array, so all you have to do is echo the $names variable, when you add more to the challenge they sometimes mark it wrong.

Aleksander Z. Cehajic
Aleksander Z. Cehajic
3,111 Points

:) thx. I'll try to keep it simple next time. ;)