how to check if a string contains numerical value and has a valid measurement unit? like 150ml
or 8.9kg
. I understand that it's doable in regex but it is not one of my strengths. What I have so far:
$validunit = array('ml', 'g', 'kg', 'lb', 'oz');
$randomstring = '3.2oz';
//check the string for numerical value and unit, display true/false
Thanks in advance.