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

Ileana Dell'Unti
Ileana Dell'Unti
2,282 Points

keep looking at videos but I can't figure out what's wrong with this code :( can someone help?

I think i get confuse somewhere between the syntax of php and html working together

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

foreach ($names as $name) {
?>
<ul>
  <li><?php echo $name?></li>
</ul>
  }

2 Answers

George Pirchalaishvili
George Pirchalaishvili
3,747 Points

You have extra ?> in your code

You can try something like this:

foreach ($names as $name) {
    echo "Value: $name<br />\n";
}
Ileana Dell'Unti
Ileana Dell'Unti
2,282 Points

I finally manage to do it!! thanks!