I have an array of recipes. Each recipe contains an array of ingredients:
[Waffle] => Array
(
[0] => stdClass Object
(
[amount] => 1
[measurement] => large
[ingredient] => egg
[grocery] => dairy
)
[1] => stdClass Object
(
[amount] => 1
[measurement] => cup
[ingredient] => milk
[grocery] => dairy
)
)
[Pancake] => Array
(
[0] => stdClass Object
(
[amount] => 1
[measurement] => large
[ingredient] => egg
[grocery] => dairy
)
[1] => stdClass Object
(
[amount] => 1
[measurement] => tablespoon
[ingredient] => maple syrup
[grocery] => pantry
)
)
I want to create a grocery list of all ingredients, compiling the amounts by ingredient and measurement, and ordered according to the grocery aisle.
So, given the above, it would output something like:
DAIRY
2 large eggs
1 cup milk
PANTRY
1 tablespoon maple syrup
Any help you can give writing a function to do this would be greatly appreciated.