Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP

Adding "R"

When I Add "R" To The Array, All The Previous Questions Mess Up.

Challenge task 7 of 7

Now let’s add another letter. Add a fourth element to the array with a value of “R” (my personal favorite). When you preview the code, notice that the count of letters increases and the new letter is added to the list automatically.

<?php

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

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

echo".";

?>

2 Answers

Hello,

Can you post the code that you have that causes the previous challenges to fail. The code you provided doesn't have the R in the code at all and works syntactically by me just looking at it. Please provide the code so I can help you figure out the error.

Cheers!

This Is The 7th Of The 7 Questions In The Introducing Arrays Challenge.

Challenge task 7 of 7 Now let’s add another letter. Add a fourth element to the array with a value of “R” (my personal favorite). When you preview the code, notice that the count of letters increases and the new letter is added to the list automatically.

When I Place The "R" In The Array With The Other Letters Like This,

<?php

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

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

echo".";

?>

Now It Accepts It!!!

I Can't Believe This, I'm Going To Bed.

Thanks Shawn...LOL