Reply to Re: ucfirst

Your name:

Reply:


Posted by BLob on 08/31/06 15:14

> 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 the
ones
> 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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация