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

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