I have a line like this:
$string = "Serving Time: 5mins
Cooking time 10 mins
Servings 4
Author: Somebody
Directions
1...
2..."
I want to get out of Cooking time, this means that the closest digit to the phrase: "Cooking time", and I also want to get a digit for the phrase "Services"
So the conclusion will be
$serves = some_kind_of_function($string);
$serves == 4; //true
$cookingtime = some_kind_of_function($string);
$cookingtime == 10 //true
What is the best way to get this?
Thank!
Adam
source
share