Leonard Burton wrote: > HI Chris, > >> Here is one option. Make a long list (array) of search/replace pairs and >> loop through your text replacing as necessary. >> >> 'mcdonald' => 'McDonald' >> 'mcdowell' => 'McDowell' >> 'o\'reilly' => 'O\'Reilly' >> 'de la rosa' => 'De La Rosa' >> etc ad nauseum... > > I think the better solution would be some pregs that would go through > and look for "mc" then have it turn the name into "Mc" then Capitalize > the next letter. [same thing for "mac"] > > Then Do the same thing with "O'Henry" it would look for "o\' " then it > would turn it into "O' " and capitalize the "H". > >> Let us know when you're done! :) > > This project shouldn't be that hard as there are probably only 10 to > 15 rules for names. give or take a few *thousand* variations alot of which will conflict, take for instance the surname prefix 'de' - in a spanish name (we'll assume Chris' example is correct) the 'd' of a 'de' prefix should be capitalized BUT in a dutch name the 'd' of a 'de' prefix should not capitalized: JOSE DE LA ROSA => Jose De La Rosa FRANK DE BOER => Frank de Boer this actual example may not be valid but I guarantee that you'll come across this kind of conflicting rules that are language/region/culture based and that you will have pretty much no chance of determining which rule to apply given just the name input. Chris' suggestion of a 1 to 1 map using an assoc array is actually probably the cleanest and most successful strategy - but rather you than me when it comes to compiling that list ;-) though please do put it online when you have completed it :-P assuming the correction that is made to the name capitalization is presented to the user you could consider asking the user whether it is correct and/of offering a number of variations (including an 'other' field) from which they could choose - this is based on the idea that you'll probably guess the capitalization wrong quite a lot of the time but that regardless of that fact you may still be able to offer an interface that is helpful to the user - even if it's not saying much more than 'HEY CHIEF, ARE YOU SURE YOU WANT YOUR NAME TO LOOK LIKE THIS?' > > Take Care, > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php