Nice easy way of capitalizing names such as “o'sullivan”?

watcheseSteve

New Member
Take two strings:\[code\]"o'sulLivAn""doUble-baRrel"\[/code\]Desired result:\[code\]"O'Sullivan""Double-Barrel"\[/code\]I thought \[code\]ucwords(strtolower($str))\[/code\] might do the trick but it treats the strings as a single word.I know I can \[code\]explode\[/code\], or rather \[code\]preg_split\[/code\] the string and then capitalize the parts and put it back together again, but I'm wondering if there's a better way of doing it?Usually with PHP and this sort of thing there tends to be a function hiding away somewhere that'd be useful but isn't obvious or well known.
 
Back
Top