-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Here is a quick replacement script* for ucwords() that can be made to handle accented characters or interesting casing rules. It is a bit uppercase happy - - uppercasing any letter that comes after a non-letter character.
*(Taken from the PHP Functions Essential Reference (http://fooassociates.com/phpfer/)) <?php function custom_ucwords($map, $string) { // A state variable that tracks if we are inside // or outside a block of word characters $inside_word = TRUE; for ($index = 0; $index < strlen($string); ++$index) { // If the current character is a key for the map array, // we know that the current character is a word character $is_chr = isset($map[$string[$index]]); /* If the last character was not a word character * but the current character is, convert the * current character to uppercase */ if (! $inside_word && $is_chr) { $string[$index] = $map[$string[$index]]; } // Track whether this character is a word or a non-word character // for the next iteration of the loop $inside_word = $is_chr; } return $string; } // A map for English characters $map = array( 'a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D', 'e' => 'E', 'f' => 'F', 'g' => 'G', 'h' => 'H', 'i' => 'I', 'j' => 'J', 'k' => 'K', 'l' => 'L', 'm' => 'M', 'n' => 'N', 'o' => 'O', 'p' => 'P', 'q' => 'Q', 'r' => 'R', 's' => 'S', 't' => 'T', 'u' => 'U', 'v' => 'V', 'w' => 'W', 'x' => 'X', 'y' => 'Y', 'z' => 'Z' ); $string = <<<_JABBERWOCKY_ "and, has thou slain the jabberwock?<br /> come to my arms, my beamish boy!<br /> o frabjous day! callooh! callay!"<br /> he chortled in his joy.<br /> _JABBERWOCKY_; echo custom_ucwords($map, $string); ?> Cheers! - --zak On September 11, 2002 08:27, Ville Mattila wrote: > I can't say correct answer to this, but want also notify that > strtoupper() -function doesn't affect to those special charters å, ä and ö > that are very common in Finnish language. > > Ville > > > -----Original Message----- > From: Tommi Virtanen [mailto:[EMAIL PROTECTED]] > Sent: 11. syyskuuta 2002 17:14 > To: [EMAIL PROTECTED] > Subject: [PHP] ucwords()? > > > Hi! > > I'll try to convert field first char to upper by using ucwords(). Well, > this doesn't > seem to work correct. > > Well maybe error came, because that characteres are not standard (they > are special characterers, finnish language). > > Example: > > $work_text = "perhepäivähoitaja"; > > $work_text = ucwords (strtolower ($work_text); > > print $work_name -> PerhepäIväHoitaja). Every char after finnish-ä is > upper. > > > How I can correct this error?? > > gustavus -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9f6nlb6QONwsK8bIRAhANAJ9Xab9JmsjKxlp+KF01822QmK8zFQCbBXW+ 92J2XRJgKmRXRAlhp7QbwTM= =QEMR -----END PGP SIGNATURE----- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php