<?php

function converttomm($size)
{
  
  if ($size != 0) {
    preg_match('`([0-9]+)(em|px|cm|pt|mm)?`', $size, $matches);
        
    if (isset($matches[2]))
      $unite = $matches[2];
    else
      $unite = '';
    
    $valeur = $matches[1];
    
    echo $unite.' - '.$valeur . ' - ';
    
    print_r($matches);
    
    if ($unite == 'cm')
      $size = $valeur*10;
    elseif ($unite == 'px') {
      $size = $valeur * 21/800;
    }
    elseif ($unite == 'pt')
      $size = $valeur*25.4/72;
    else
      $size = 0;
  }
  
  return $size;
}

echo converttomm("8px").'<br>';
echo converttomm('3cm').'<br>';
echo converttomm('15pt').'<br>';


?>