Re: ucfirst
- From: "BLob" <blob@xxxxxxxxxxxxxx>
- Date: Thu, 31 Aug 2006 17:14:27 +0200
I have abunch of names that I'd like to normalize case-wise. Some are
lowercase (joe jackson), some uppercase (JOE JACKSON), and some correctly
cased (Joe Jackson). ucfirst(strtolower('JOE JACKSON')); works for most
cases, but if there's a name with a hyphen, ie. BILLY-BOB JOHNSON and
jack-bob johnson and Bob-Bob Johnson, they're turned into Billy-bob etc...
Lucky you if "your" names do not have accents signs (meaning é, è, ê and
others) ! Otherwise your method wouldn't work, as it would transform
"STEPHANE" into "Stephane" ("STEPHANE" is correct because capital letters do
not take accents, whereas "Stephane" should be written "Stéphane").
The letter after the hyphen should be uppercased as well, not just theones
after space. Anyone got idea how to do this?
A dirty trick :
Replace "-" by "- ".
Then do your ucfirst(strtolower($name));
Them replace back "- " by "-".
That should do it !
BLob
.
- References:
- ucfirst
- From: Kimmo Laine
- ucfirst
- Prev by Date: Re: newbie question: using $_POST inside of array parameters?
- Next by Date: Re: how to Replicate Session in new window?, target _blank
- Previous by thread: ucfirst
- Next by thread: how to get url ?
- Index(es):
Relevant Pages
|