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!

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

General Discussion

Krystel Hagan
Krystel Hagan
4,731 Points

Accounting for Empty results 3/3

Q: Let's make sure that foreach loop executes correctly if the $recommendations array is NOT empty. Add one element to the $recommendations array with a value of 'Avocado Chocolate'. A:


$recommendations = array();
    $recommendations[] = 'Avocado Chocolate';

?> <html> <body>

<h1>Flavor Recommendations</h1>

<?php if(!empty($reccomendations)) { ?>

    <?php foreach($recommendations as $flavor) { ?>
        <li><?php echo $flavor; ?></li>
    <?php } ?>
    <?php } else { ?>
    <?php echo '<p>There are no flavor recommendations for you.</p>'; ?>
<?php } ?>

</body> </html>'''

I do not understand what I need to do. It just keeps saying "Bummer! Please try again!"

2 Answers

Andrew Shook
Andrew Shook
31,709 Points

You misspelled $recommendations inside the empty() function call. Too many c's not enough m's.