avatar
Michael Kilpatrick @mtkilpatrick.bsky.social

1/ Well, this ballooned somewhat! I just wanted a PHP script to add to my band website that would tidy up people's names in my ticket database. It annoyed me seeing some names all in lower case, others all in upper case. The resulting script got rather out of hand!

Screenshot of PHP code for normalising names entered with poor upper/lower case. image image
jun 26, 2025, 1:17 pm • 2 0

Replies

avatar
Michael Kilpatrick @mtkilpatrick.bsky.social

2/ I mean, if someone writes CA Roberts or C A Roberts or C.A. Roberts, you can't be sure "CA" isn't a two-letter name (Li, Wu..?) but you can format the rest in a consisent manner. You can also put the initials at the front so that Roberts C A becames C A Roberts.

jun 26, 2025, 1:19 pm • 1 0 • view
avatar
Michael Kilpatrick @mtkilpatrick.bsky.social

3/ and if they write jenny smith or JENNY SMITH, you can convert it to Jenny Smith. Easy. Erm... But what if their name is McInnes or MacDonald, or Machi? How do you differentiate the last two without a dictionary of Scottish surnames and they write it all in lowercase? You don't.

jun 26, 2025, 1:22 pm • 1 0 • view
avatar
Michael Kilpatrick @mtkilpatrick.bsky.social

4/ But if they've got their CAPSLOCK accidentally inverted and write mACdONALD, you *know* it should be MacDonald. So you can make intelligent guesses based on the case of the second half of the name.

jun 26, 2025, 1:23 pm • 1 0 • view
avatar
Michael Kilpatrick @mtkilpatrick.bsky.social

5/ Also they might right "Robert R Brown" and you need to know that middle initial wants to stay where it is, so that needs to accounted for also. Sorted. Erm, but what if they are Dutch?

jun 26, 2025, 1:24 pm • 0 0 • view
avatar
Michael Kilpatrick @mtkilpatrick.bsky.social

6/ Their name could be Susan van de Ven or Aiden Van De Meyer. (Some non-Dutch have normalised the capitalisation so the Van might not be van). What about "Daphne du Maurier"? There are sets of particles in some languages to look out for, so the script does that too!

jun 26, 2025, 1:26 pm • 0 0 • view
avatar
Michael Kilpatrick @mtkilpatrick.bsky.social

7/ But it has to avoid falsely changing the case of two-letter names such as "Li", and so the search for particles "van de" de la", "du", etc, is separate from the logic that differentiates names such as "Li" from pairs of initials such as "CJ", primarily based on whether there's a vowel or not.

jun 26, 2025, 1:28 pm • 0 0 • view
avatar
Michael Kilpatrick @mtkilpatrick.bsky.social

8/ Blimey, it's an absolute mess. But I think I ended up with a solution that normalises most names if they are entered with stupid upper/lower case inconsistencies, and accounts for strange names, strange positioning of articles, and also puts Mr/Miss/Dr/Prof/etc always at the front.

jun 26, 2025, 1:30 pm • 0 0 • view
avatar
Michael Kilpatrick @mtkilpatrick.bsky.social

9/ All this because I couldn't stand the fact that a few people had bought tickets to Harmony In Harlem concerts but put their name as "judith smith" or "DR C BURT" rather than "Judith Smith" and "Dr C Burt". Oops. That's several days of life I won't get back!

jun 26, 2025, 1:32 pm • 0 0 • view