U can try this:

function fNme($n){
        $tN=count($n=explode(' ',strtolower($n)));
        $nR='';
        
for($i=0;$i<$tN;$i++){if($i==0){$nR.=strlen($n[$i])>3?ucwords($n[$i]):$n[$i]
;}else{$nR.=strlen($n[$i])>3?' '.ucwords($n[$i]):' '.$n[$i];}}
        return $nR;
}
        
echo fNme('aaaaa aaa aaaaaa aa aaaa');

And also make an array inside this function for exceptions like 'vander' or
other words which the srtlen is > 3.

Zechim

-----Mensagem original-----
De: phphelp -- kbk [mailto:phph...@comcast.net] 
Enviada em: quinta-feira, 16 de julho de 2009 15:00
Para: PHP General List
Assunto: [PHP] Case Conversion of US Person Names

Hi, All -- -- - -

I occasionally find myself in need of a utility to do case conversion  
of people's names, especially when I am converting data from an old  
to a new system. This is the first such occasion in PHP.

I know about ucwords() and mb_convert_case(). They do not accommodate  
names with "middle" capitalization.

Does anybody have such a utility to share, or know of one posted by  
someone "out there" that you have used?

I am not looking for perfection -- I know that such is not possible.  
I just want to pick off the easy ones -- Mc, Mac, O', de, de la, van,  
vander, van der, d' and others like that. I see some novel attempts  
to do parts of this on the PHP ucwords() "User Notes" area, but I bet  
someone out there has something more comprehensive. I'd rather not  
"roll my own" as I have done in other languages.

I have Googled without success.

Many thanks,


Ken

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to