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 Enhancing a Simple PHP Application Refactoring the Codebase Separating Concerns: MVC

Fabian Wilson
Fabian Wilson
5,076 Points

So I am stuck on this challenge.

I have copied the code to my server for testing and it works with the code below. For some reason I cannot get past this challenge.

<?php
// CONTROLLER CODE
$flavors = get_flavors_by_likes(3);


 foreach ($flavors as $flavor ) {
            echo "<li>" . $flavor["name"] . ("\n"  . "+") . $flavor["likes"] . "</li>";
        }
?>
Colin Marshall
Colin Marshall
32,861 Points

Fabian Wilson, when answering your post I discovered that you must wrap any php code you put on the forum in php tags to get the syntax highlighting to work, even if you declare the language as php after the tick marks. I edited your post to add the syntax highlighting.

Cheers,
Colin

2 Answers

Colin Marshall
Colin Marshall
32,861 Points

Your concatenation is incorrect for the space and plus sign part. It should look like this:

<?php

$flavors = get_flavors_by_likes(3);

foreach ($flavors as $flavor ) {
    echo "<li>" . $flavor["name"] . " +" . $flavor["likes"] . "</li>";
}

?>
Fabian Wilson
Fabian Wilson
5,076 Points

Thanks Colin that worked.