Clean Capitalising of Names
Posted: Sat May 10, 2008 6:20 pm
I need a script to capitalize people's names.
Ie someone enters jiM mCDonalD - it returns Jim McDonald
Below sets all to lower case and then changes first lettter - but I get Jim Mcdonald (ie some letters should / should not be capitalised)
I am not bothered about the 0.1% of weird names, but there are a lot of Mc names about etc.
Anyone got a script hanging around?
Ie someone enters jiM mCDonalD - it returns Jim McDonald
Below sets all to lower case and then changes first lettter - but I get Jim Mcdonald (ie some letters should / should not be capitalised)
I am not bothered about the 0.1% of weird names, but there are a lot of Mc names about etc.
Anyone got a script hanging around?
Code: Select all
<?php
//first, converts to lower case, then sets first letter as capital (must set first to lowercase)
$name = "jim brown";
$name2 = strtolower($name);
$name3 = ucwords($name2);
echo $name3;
?>