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: 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,622 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....