switch($type) { case 'dt': if(preg_match('/^(\d\d?)-(\d\d?)-(\d\d\d\d)$/', $value, $m)) { return sprintf('%02d-%02d-%d', $m[1], $m[2], $m[3]); }