I need to extract the quantity and unit from strings like this
1 tbsp
1tbsp
300ml
300 ml
10grams
10 g
The quantities will always be numbers, then there may or may not be a space then the unit. They may be 15 - 20 different units which can come from a list that we define (perhaps an array)
The solution can be in either javascript or PHP as I need to split them before storing them in a database. ie they need to be stored separately.
Thanks
EDIT: Sorry to be clear. Each new line represents a new string. That is the string would only contain 10g OR 300ml - so we just need to split one unit and one quantity at a time.