I need a function which converts uppercase the first letter of the word, except when its length is less than 3 chars.
Example:
echo function('abcd xe efg hij'); //Abcd xe Efg Hij
echo function('aBcd X efg'); //Abcd x Efg
May be trying to improve this will solve. adding something to the delimiter array
function ucname($string) {
$string =ucwords(strtolower($string));
foreach (array('-', '\'') as $delimiter) {
if (strpos($string, $delimiter)!==false) {
$string =implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
}
}
return $string;
}
Any ideas? Many thanks.