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

Fran Levy
Fran Levy
351 Points

What am I supposed to display in Task 6?

Task 6 seems to be asking for contradictory results. If I display just 1 letter from the array, it asks me to display all 4 letters. But if I display all 4 letters from the array, it tells me to display just 1. What is this asking? I'm utterly stuck.

letters.php
<?php

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

echo "My favorite ";
echo count($letters);
echo " letters are these:";

foreach($letters as $letter) {
  echo $letters[4];
}
echo ".";

?>

2 Answers

<?php

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

echo "My favorite ";
echo count($letters);
echo " letters are these: ";

foreach($letters as $letter) {
  echo $letter;
}
echo ".";

?>

Will display:

My favorite 4 letters are these: DGLR.

Fran Levy
Fran Levy
351 Points

Thanks for your response, mikes02! I refreshed my browser and tried again on my own right after I posted my question. I got it to work properly the second time around; apparently that question was redundant, since I had already done what it asked for in Task 5.