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

Foreach challenge what actually want from me?

The challlenge is: Using a foreach, create a loop that goes through each of the names in the $names array.

I couldnt understand the challenge actually. What that challenge actually want? I think I couldnt understand because of my english level. Can anybody help me to understand the challenge?

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

?>

2 Answers

Kuai Cheang
Kuai Cheang
17,931 Points

Hi, the question is asking for you to create a loop that will go through each name in the $names array, so something like:

foreach($names as $name) {

}

You do not need to write anything until second question. Hope it helps

Michael Oliver
Michael Oliver
7,855 Points

I have no language barrier, but I feel the questions in the challenges are a little vague, the code seems even a bit redundant.