Hello all.
I am working on a Cooking Recipes profile and have a field recipe_nutrition where I add the nutritional values in a textarea field like:
Calories: 2000kj
Fat: 10gr
Carbohydrate: 10gr
Protein: 50gr
Vitamin C: 10mg
Iron: 20mg
So I am using the explode function to separate the lines and it works fine (if I am just styling the values as text list), but now I would like to take the text content before and after the colon and add them in a table. Also I need to find first the line that contains Calories and print the value in frontend. As far as the lines are not added in a specific order, the Calories: 2000kj could be first, second, third line etc.
In the perfect scenario the line should be checked for a specifict text (in my case Calories) and if it contains it to get the text after the : sign.
Maybe there is a better approach to using API and modules to achieve a simple Nutrition table with all the values without creating a field for every value but grabbing it from a text content or else? Check the image for better understanding of the goal.