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 trialElinor Armsby
13,987 Pointsonly returns recipes with 1 tag
When I added all the same code as shown in the video, it works but only returns recipes that have only 1 tag as "breakfast." Recipes tagged like "breakfast, quick bread" are not returned. I'm not quite understanding why. It seems to be tied to this method of the recipe collection class:
public function filterByTag($tag)
{
$taggedRecipes=array();
foreach ($this->recipes as $recipe){
if(in_array(strtolower($tag), $recipe->getTags())){
$taggedRecipes[]=$recipe;
}
}
return $taggedRecipes;
}
Perhaps the use of in_array
? When I var_dump
ed the getTags()
for each recipe, they are not arrays but comma-delimited strings. So, maybe that's the issue?? Confused...