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

Challenge Task 1 of 3 Stage 4

Challenge Task 1 of 3

This code creates an array of ice cream flavors and then displays them in an index.php file. However, we now also need the array of ice cream flavors in another file. Let's move the flavors array into a model file. First, in flavors.php, create a new function called get_all_flavors().

index.php
<?php

// ==== INCLUDE MODEL FILE ====
require_once('flavors.php');

$flavors = array(
        "Jalapeno So Spicy",
        "Avocado Chocolate",
        "Peppermint",
        "Vanilla",
        "Cake Batter",
        "Cookie Dough"
    );

?>

1 Answer

Hugo Paz
Hugo Paz
15,620 Points

Hi,

You need to pick the flavors.php tab. Then you can add the code to create the function.

Thank you very much Hugo it worked....