I'm trying to extract some metric sizes from strings example:
Example:
$s1=" foobar 10mm bar" // 10mm
$s2=" foobar 10-300ml barbr" // 10-300ml
$s3=" foobar 25 - 70 cm foo" // 25-70cmm
How do I go about it ?
I've tried this so:
$sizes_volume_distance_markers = array('mm','ml','l','cm');
static $pattern_final_voldist;
if(!$pattern_final_voldist)
{
$pattern_final_voldist = implode("|",self::$sizes_volume_distance_markers);
}
if(preg_match_all("/([\d.-]{1,4}[\s.-]{0,2}($pattern_final_voldist) {1,2})+/i",$str,$vvalues))
{
var_dump($vvalues);
}