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 Build a Simple PHP Application Listing Inventory Items Introducing Arrays

mohammed hussain
mohammed hussain
4,949 Points

Challenge task 5 of 7 - loading of arrays

i cannot understand the question. Can someone please help me.

2 Answers

Stone Preston
Stone Preston
42,016 Points

you need to add a foreach loop that loads each item in the array into a working variable called $letter. for each loops generally look like this:

foreach ($array as $workingVariable) { 

}

where $array is the array you want to loop through and $working variable is a the variable that each item in the array is loaded into as it loops through the array. you need to add a foreach loop here:

<?php

$letters = array("D", "G", "L");

echo "My favorite ";
echo count($letters);
echo " letters are these: ";
//start your foreach loop right here
echo "AB";
//close your loop here

echo ".";

?>