note 19450 deleted from function.strtolower by nlopess
| From: | nlopess@php.net | Date: | Sat, 07 Feb 2004 10:10:14 +0000 |
| Subject: | note 19450 deleted from function.strtolower by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-64765@lists.php.net to get a copy of this message | ||
Note Submitter: http://www.csaszar.org
----
This is a de-hyphenating function. It's used to transform names into valid linux usernames.
Eg.: MaríaÖtinger2002 ==> maria.otinger2002
function de_hyphen($txt) {
$txt = strtr($txt,
"ÁÉÍÓÚÑÀÈÌÒÙÄËÏÖÜÂÊÎÔÛáéíóúñàèìòùäëïöüâêîôûç",
"aeiounaeiouaeiouaeiouaeiounaeiouaeiouaeiouc");
$txt = strtolower($txt);
$n = strlen($txt);
for($i = 0; $i<$n; $i++) {
$a = substr($txt, $i, 1);
if ((($a>="a") && (a<="z")) ||
(($a>="0") && ($a<="9")) || ($a==".")) {
$new = $new . $a;
}
}
return $new;
}