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 trialJames Wrest
3,480 Pointshow to echo the 3 names correctly
not sure what i did wrong
<?php
$names = array('Mike', 'Chris', 'Jane', 'Bob');
foreach($names as $name){
echo "$name"};
?>
2 Answers
Sebastian Wilson
15,710 PointsHi, in your foreach your are missing a semicolon and you do not need one at the end of your } .
<?php
$names = array('Mike', 'Chris', 'Jane', 'Bob');
foreach($names as $name) { echo "$name "; }
?>
William Li
Courses Plus Student 26,868 PointsThe problem is the misplacing ; in the code.
<?php
$names = array('Mike', 'Chris', 'Jane', 'Bob');
foreach($names as $name) {
echo $name;
}
?>