PHP 8.5.0 Alpha 4 available for testing

Voting

: four minus two?
(Example: nine)

The Note You're Voting On

deepdene at email dot com
22 years ago
A function knowing about name case (i.e. caps on McDonald etc)

function name_case($name)
{
$newname = strtoupper($name[0]);
for ($i=1; $i < strlen($name); $i++)
{
$subed = substr($name, $i, 1);
if (((ord($subed) > 64) && (ord($subed) < 123)) ||
((ord($subed) > 48) && (ord($subed) < 58)))
{
$word_check = substr($name, $i - 2, 2);
if (!strcasecmp($word_check, 'Mc') || !strcasecmp($word_check, "O'"))
{
$newname .= strtoupper($subed);
}
else if ($break)
{

$newname .= strtoupper($subed);
}
else
{
$newname .= strtolower($subed);
}
$break=0;
}
else
{
// not a letter - a boundary
$newname .= $subed;
$break=1;
}
}
return $newname;
}

<< Back to user notes page

To Top