1 00:00:00,420 --> 00:00:02,500 Okay, we're starting to get somewhere. 2 00:00:02,500 --> 00:00:06,670 Now I want to be able to pull only the recipes with a particular tag. 3 00:00:07,700 --> 00:00:09,535 Let's go back to our recipe collection. 4 00:00:15,995 --> 00:00:19,215 We'll create a new method called filterByTag. 5 00:00:25,274 --> 00:00:30,455 We'll pass in the value of the tag that we want to look for. 6 00:00:30,455 --> 00:00:33,935 We'll initialize a new taggedRecipes array. 7 00:00:40,195 --> 00:00:43,435 Then we can loop through the recipes and look for our tag. 8 00:00:55,515 --> 00:01:02,895 We can use if in_array, we're going to make sure that our tag is lowercase. 9 00:01:02,895 --> 00:01:04,335 We use strtolower. 10 00:01:06,394 --> 00:01:07,314 And our tag. 11 00:01:09,415 --> 00:01:12,394 Then we'll be looking in the recipe getTags. 12 00:01:17,354 --> 00:01:21,495 If we find the tag, we'll add this recipe to our taggedRecipes. 13 00:01:33,715 --> 00:01:36,675 Finally, we'll return our taggedRecipes. 14 00:01:39,655 --> 00:01:42,355 Let's go back to our cookbook and use our new filter. 15 00:01:45,295 --> 00:01:48,715 I'm going to create a new recipe collection. 16 00:01:48,715 --> 00:01:52,154 This is going to be for any recipe tagged breakfast. 17 00:02:08,475 --> 00:02:15,395 Then we can loop through the breakfast recipes after we filter by tag. 18 00:02:15,395 --> 00:02:16,415 Here's our filter. 19 00:02:20,775 --> 00:02:22,044 And we pass it breakfast. 20 00:02:24,984 --> 00:02:27,604 Then we'll return each of these as recipe. 21 00:02:31,684 --> 00:02:35,384 Then we're going to add this recipe to our breakfast collection. 22 00:02:43,823 --> 00:02:46,244 Now let's render our breakfast recipes instead. 23 00:02:55,244 --> 00:02:59,060 Now we see just the recipes that were tagged as breakfast. 24 00:02:59,060 --> 00:03:02,290 There's one more feature that I'd like to see for our collection. 25 00:03:02,290 --> 00:03:03,660 A shopping list. 26 00:03:03,660 --> 00:03:05,440 We'll dive into that in the next video.