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

Displaying too many letters?

On the introducing arrays challenge, I end up with too many letters - DGLL instead of DGL. I don't see what it is that is wrong with the code.

<?php

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

echo "My favorite ";
echo count($letters);
echo " letters are these: "; {
    foreach ($letters as $letter){
    echo $letter; }
echo $letter; }
echo ".";

?>

My favorite 3 letters are these: DGLL.

2 Answers

@Elizabeth - You have an extra echo $letter;

Try this code, it should get you sorted out

For future reference when posting PHP it's often easier to troubleshoot if you post a "working" version using a PHP Sandbox

Also if you are working on a specific code challenge/quiz/video it's often helpful to post a link to that and mention at what point you got stuck.

Remove the last echo $letter;