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 trialAgustin Villa
1,695 PointsWith the preview the array seems to display properly. Error is that i am not using the same array which i defined
Any help would be awesome. Thanks
1 Answer
iainwb
Courses Plus Student 2,437 PointsI had this error too, it appears if you (as an example) do the following it fails:
<?php
$names = array('Mike', 'Chris', 'Jane', 'Bob');
foreach( $names as $person ){
echo $person;
}
?>
This is because the Challenge checker sees a problem with the extra spaces in the foreach parenthesis. If you change this to the following it works (I've literally just removed the space before $name and after $person):
<?php
$names = array('Mike', 'Chris', 'Jane', 'Bob');
foreach($names as $person){
echo $person;
}
?>
This said, the top example that fails the Challenge works if you actually create this in Workspaces or on a web server. I don't know whether it's considered a bad practice to add the spaces or not, or if it's just a quirk of the Challenge checker?
Casey Ydenberg
15,622 PointsCasey Ydenberg
15,622 PointsPlease post the code you have tried.