Suggestions for correcting people's names, so they are capitalized correctly

Users of our site often print a lot of garbage for information about the name and address. e.g. all CAPS, all lower, etc.

It looks a lot better if we fix them for them, but someone can suggest a good way to do it. A simple approach is only to use each word in its own name, but this does not work when working with some names. Here are some examples ...

  • bob mcdonald
  • sarah o'connor
  • MR PETE SMITH

and this is what I would like to convert to

  • Bob mcdonald
  • Sarah O'Connor
  • Mr. Pete Smith

I use PHP if this helps.

+3
source share
4 answers

, , , , , .

O'Connor O'connor. , , - , O'Connor, Oconnor, . - . "bob smith", .

, , , - ALL-CAPS . , , -, , .

+7

. , , ?

, , .

  • , ""
  • (, , "mc" )

- , , , . , , - , , , , - . , , , .

+9

, , , , . , "" . "Developer Art", , , .

+4

$name = ucwords(strtolower($name)); PHP, , .

+3

Source: https://habr.com/ru/post/1721089/


All Articles