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 Object-Oriented PHP Basics Building the Recipe Populating the Recipes

Observation RE: addTag();

This is just an observation.

When we add a tag to a recipe, we have it set-up singular to add one tag at a time.

public function addTag($tag)
        $this->tags[] = strtolower($tag);

But the recipes Alena provided us with to populate the recipes have several tags, and are not comma separated. A few examples....

$belgian_waffles->addTag("breakfast, quick bread");
$granola_muffins->addTag("breakfast, snack, quick bread");

For me personally, this will cause problems in the future lessons when displaying the Recipe Titles that are filtered by a tag. For example, to find the belgian waffles recipe using a tag filter, you would need to add the argument as "breakfast, quick bread" instead of just "breakfast" for example.

I look forward to receiving your insight on this. Is there a reason I am overlooking?

Thanks in advance!

1 Answer

I haven't done it myself so not overly sure but I think the commas found in

$belgian_waffles->addTag("breakfast, quick bread");

are used to add new items to the array. In this case two items, breakfast and quick bread, are being added to the array.