<?php
function FormatName($name=NULL) {
/* Formats a first or last name, and returns the formatted
version */
if (empty($name))
return false;
// Initially set the string to lower, to work on it
$name = strtolower($name);
// Run through and uppercase any multi-barrelled names
$names_array = explode('-',$name);
for ($i = 0; $i < count($names_array); $i++) {
// "McDonald", "O'Conner"..
if (strncmp($names_array[$i],'mc',2) == 0 || ereg('^[oO]\'[a-zA-Z]',$names_array[$i])) {
$names_array[$i][2] = strtoupper($names_array[$i][2]);
}
// Always set the first letter to uppercase, no matter what
$names_array[$i] = ucfirst($names_array[$i]);
}
// Piece the names back together
$name = implode('-',$names_array);
// Return upper-casing on all missed (but required) elements of the $name var
return ucwords($name);
}
?>
http://dk2.php.net/manual/da/function.ucfirst.php