(single word)
abc => Abc ... working
(one or two chars in the middle of the words, small case)
abcd xe efg hij => Abcd xe Efg Hij ... not working
abcd x efg => Abcd x Efg ... not working
(one or two chars in beginning or end, upper case)
ab cde => Ab Cde ... working
abc de => Abc De ... working
a bc => A Bc ... working
(if it has a point)
ab.cd => Ab.cd
(other char)
abc - de => Abc - De
Code: Select all
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;
}