Re: RES: [PHP] Case Conversion of US Person Names

From: Date: Thu, 16 Jul 2009 19:33:03 +0000
Subject: Re: RES: [PHP] Case Conversion of US Person Names
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-295487@lists.php.net to get a copy of this message
On Jul 16, 2009, at 1:19 PM, Jônatas Zechim wrote:
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.
Thank you. If I "roll my own" function, that could be useful. I'd still rather find one that exists, though. Ken

« previous php.general (#295487) next »