Capitalizing names ... needs the final touch...

From: Date: Mon, 07 Oct 2002 21:26:19 +0000
Subject: Capitalizing names ... needs the final touch...
Groups: php.general 
Request: Send a blank email to php-general+get-119146@lists.php.net to get a copy of this message
Hi gang I need some help getting this thing fully correct: I pass a variable called $name like this (test-string): girlz.php?locat=bio&name=firstname_middlename_last-name and need to 1. remove the underscores, 2. capitalize all name parts. After going through just about every command in the manual about this, I've ended up with this: // pull real name out of $name $realname = ""; $tok = strtok($name,"_"); // strtok = tokenizer while ($tok) { $realname .= $tok." "; // paste tokens together $tok = strtok("_"); // next token } $realname = trim($realname); // remove unneeded whitespaces $realname = ucwords($realname); // capitalize words // end namegame Okay ... so far so good. When feeding this the test string: firstname_middlename_last-name I get this: Firstname Middlename Last-name But I want the last namepart after the slash (-name) to also start with a capital letter. Isn't there some easy way to do this? If I have to go through a FOR routine, it kinda ruins the idea of ucwords() in the first place, so I'd rather avoid that if at all possible. Also, I'd like it to correctly be able to also correctly capitalize Irish and Scottish names (like O'Connor, and MacDonald). Any idea how to do this would be appreciated ... I'm pretty sure it's just a matter of combining the right string commands... TIA Rene -- Rene Brehmer System developer in the making... This message was written on 100% recycled spam. My website: http://www.geocities.com/cerberus_hotdog Babes and computer & internet references...

« previous php.general (#119146) next »