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

Steven Horan
Steven Horan
6,647 Points

PHP Listing Inventory Items: Code Challenge: More Excitement With Arrays (4 of 7 ) Not recognizing correct answer

Bummer! The page is not displaying the correct number of flavors; it should say we have 3 flavors.

code: <?php $flavors = array(); $flavors[] = "Chocolate"; $flavors[] = "Vanilla"; $flavors[] = "Peppermint"; ?> <p>Welcome to Ye Olde Ice Cream Shoppe. We sell <?php echo count($flavors); ?> flavors of ice cream </p> <ul> <?php foreach ($flavors as $flavor){ ?> <li><?php echo $flavor; ?></li> <?php } ?> </ul>

4 Answers

I just reran through the question, and used <?php echo count($flavors) ?> and it worked fine. I see that you have jumped a few steps and already displayed the list of flavors. Maybe that is causing the issue, I'm not sure though. try the challenge without jumping ahead and see if it works for you.

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

Hmmm ... I think the issues is that you have too many spaces between the number and the word flavors. The code challenge is looking for this ...

3 flavors

... but I think you have this (with two spaces):

3  flavors

That extra space probably shouldn't matter; the browser won't display two spaces together like that. I'll see what I can do to get that fixed, but hopefully you can get passed that by removing the extra space.

I'm also having this issue

<?php

$flavors = array ("Chocolate", "Vanilla", "Dog Food");

?> <p>Welcome to Ye Olde Ice Cream Shoppe. We sell <?php echo count($flavors); ?> flavors of ice cream.</p> <ul> <li><?php echo $flavor1; ?></li> <li><?php echo $flavor2; ?></li> </ul>

started again and used the same answers and it worked.. frustrating..