peppericious Posted April 25, 2012 Share Posted April 25, 2012 I'm presently formatting surnames like this: $surname = ucfirst(strtolower($surname))) .. so that SMITH, and smith ... both look like: Smith. That's all fine, but how do I ensure that... O'BRIEN o'brien o' brien ... all look like O'Brien ? That is, where no spaces are allowed to appear in the surname and where the first letter, as well as the one following the apostrophe are both capitalised. TIA Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/ Share on other sites More sharing options...
Jessica Posted April 25, 2012 Share Posted April 25, 2012 Hmmm... I would explode on spaces and ' (spaces for things like Von Deutch) and do ucwords on both, then implode them back together. Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340493 Share on other sites More sharing options...
xyph Posted April 25, 2012 Share Posted April 25, 2012 Gotta watch out. Muslim: Abd al-Iiaah Dutch: Mark van der Zalm .. and probably many more. There's a lot to look out for. Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340499 Share on other sites More sharing options...
peppericious Posted April 25, 2012 Author Share Posted April 25, 2012 That explode/implode solution looks promising, jesirose. Maybe, in light of what you say xyph, I could put the explode needles in an array, and loop through a number of explodes?... Does that sound crazy?... Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340501 Share on other sites More sharing options...
kicken Posted April 25, 2012 Share Posted April 25, 2012 There's also things like McDonald where you'd just have to check for specific prefixes. Ideally you should just give the user the ability to enter their name as they want it displayed rather than try and format it yourself. Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340505 Share on other sites More sharing options...
Jessica Posted April 25, 2012 Share Posted April 25, 2012 There's also things like McDonald where you'd just have to check for specific prefixes. Ideally you should just give the user the ability to enter their name as they want it displayed rather than try and format it yourself. I have to agree. Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340508 Share on other sites More sharing options...
Psycho Posted April 25, 2012 Share Posted April 25, 2012 There's also things like McDonald where you'd just have to check for specific prefixes. Ideally you should just give the user the ability to enter their name as they want it displayed rather than try and format it yourself. I have to agree. I'll second (or would it be third) that. You will NEVER get 100% accuracy. If you force the format based upon your rules you are going to save some names incorrectly. Granted, it might be a small percentage, but will sure makes those users unhappy. I have the problem that my last name routinely has an apostrophe added in many mailings I receive - even though I don't use one. It's disappointing to see that, but not a huge deal. But, if a website did that to my name and how it was displayed on that site I would be looking for a support email or phone number to voice my complaint. If you cannot get all the names correct then don't even try. Unless you are going to format it and then let the user approve it first. Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340519 Share on other sites More sharing options...
peppericious Posted April 25, 2012 Author Share Posted April 25, 2012 My plan, in fact, was to store surnames as entered and then apply some rules when echoing the names back out. Given your advice, though, perhaps it's best to just echo the names back out as submitted, too. Thanks for all your help. Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340525 Share on other sites More sharing options...
Jessica Posted April 26, 2012 Share Posted April 26, 2012 There's also things like McDonald where you'd just have to check for specific prefixes. Ideally you should just give the user the ability to enter their name as they want it displayed rather than try and format it yourself. I have to agree. I'll second (or would it be third) that. You will NEVER get 100% accuracy. If you force the format based upon your rules you are going to save some names incorrectly. Granted, it might be a small percentage, but will sure makes those users unhappy. I have the problem that my last name routinely has an apostrophe added in many mailings I receive - even though I don't use one. I've had several instances of websites thinking they are smarter than me like this recently when trying to do security questions. Apple just recently made me pick 3 security questions. One of the options for the first question was "What was your first car". The third question option was "What was your least favorite car?". It wouldn't let me have the same car for both. Really Apple? My least favorite car WAS that car!! The worst though is when websites tell me my mother's maiden name must be longer than 3 characters. Funny, her birth certificate says otherwise... Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340673 Share on other sites More sharing options...
ManiacDan Posted April 26, 2012 Share Posted April 26, 2012 Any time you place restrictions on the user, especially for personal information, you're going to run into problems. Let them decide how their last names are capitalized, especially since there ARE no rules. Macdonald and MacDonald are both acceptable capitalizations. Also, Jesi, and someone who once dated a Koh, I feel your pain for the string length limits on name fields. Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340677 Share on other sites More sharing options...
Jessica Posted April 26, 2012 Share Posted April 26, 2012 Also, Jesi, and someone who once dated a Koh, I feel your pain for the string length limits on name fields. It goes the other way too. I work with a lot of people who have names so long they word wrap in the terminal. *drum crash* Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340678 Share on other sites More sharing options...
Psycho Posted April 26, 2012 Share Posted April 26, 2012 I've had several instances of websites thinking they are smarter than me like this recently when trying to do security questions. Apple just recently made me pick 3 security questions. One of the options for the first question was "What was your first car". The third question option was "What was your least favorite car?". It wouldn't let me have the same car for both. Really Apple? My least favorite car WAS that car!! Hold on a minute! Are you trying to say that Apple, of all companies, would actually implement some type of limiting ability and would think it was prudent or even preferred? Heck they might even refer to some such implementation as a "feature". I mean, c'mon, Apple and particularly it's user base are the epitome of humbleness. It's as if you might be implying that Apple would, in some way, be a little arrogant in thinking it is superior. Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340704 Share on other sites More sharing options...
Jessica Posted April 26, 2012 Share Posted April 26, 2012 I've had several instances of websites thinking they are smarter than me like this recently when trying to do security questions. Apple just recently made me pick 3 security questions. One of the options for the first question was "What was your first car". The third question option was "What was your least favorite car?". It wouldn't let me have the same car for both. Really Apple? My least favorite car WAS that car!! Hold on a minute! Are you trying to say that Apple, of all companies, would actually implement some type of limiting ability and would think it was prudent or even preferred? Heck they might even refer to some such implementation as a "feature". I mean, c'mon, Apple and particularly it's user base are the epitome of humbleness. It's as if you might be implying that Apple would, in some way, be a little arrogant in thinking it is superior. I love my iPhone, hate all other Apple products. (Well I guess the iPad isn't bad, I got a TouchPad instead). My husband has a Mac and I refuse to use it. Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340708 Share on other sites More sharing options...
ManiacDan Posted April 26, 2012 Share Posted April 26, 2012 Hooray, an apple complaint thread! Every single apple product, when a button is pushed, does what Apple believes you really meant. They take form over function to the logical extreme. My iPod doesn't pause or skip tracks when I hit the pause button if I've hit the center button in the last 15 seconds (because it refuses to affect the track in anything other than "volume control" mode). I had a mac for a long time when OSX first came out, and I couldn't get used to it. It just never did what I wanted it to do, it always got really close. I tried to switch to the iPhone, I borrowed one and used it for a few days. It just doesn't let you do what you want to do. I understand their design philosophy insists that everything be perfect, but what if I want an imperfect feature, or I want to install my own stuff? Maybe Jesi doesn't want turn by turn GPS, a text terminal, or the ability to play internet radio while using an NES emulator, but all of those things I do every day. Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340766 Share on other sites More sharing options...
Jessica Posted April 26, 2012 Share Posted April 26, 2012 Well I don't want those things on my phone, no. I've had 3 iPhones and will get the next one that comes out. I'm a creature of habit. My phone before the iPhone was a Razr. When it broke my at-the-time SO had an iPhone and I hated it. I tried like 5 other smart phones from AT&T (what they had at the time sucked of course) and eventually used his iPhone and gave in and got one. It's perfect for what I want to do on my phone. Just like a Windows PC is perfect for me for what I want to do on my laptop or desktop. The TouchPad is close enough for what I want in a tablet. Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340768 Share on other sites More sharing options...
ManiacDan Posted April 26, 2012 Share Posted April 26, 2012 I wonder if you'd be less happy with your iPhone after using an android phone for a while. There's just so much more I can do. Do you have a standalone GPS? That's usually the selling point for people, I can actually push a button and say "Navigate to Susan's home" and the lady starts telling me where to turn. Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340772 Share on other sites More sharing options...
Jessica Posted April 26, 2012 Share Posted April 26, 2012 I had a GPS a few years ago but it got stolen. I've never needed turn-by-turn, I just look at the map and know which way to turn... I've always found speaking GPS systems to be annoying. My husband and I used one for a few days on a road trip and both hated it, we both prefer to look at the map and know the route ahead of time rather than have someone tell us constantly which way to go. I personally think those things are over rated, but that's just me. and him lol. Actually I think my car comes with a GPS...I just never use it. I've tried using my parent's andriods as well as ones my husband's work gives him and I don't like them. I don't want to do more with my iPhone than what it currently can do. I don't even use a lot of the features it has. Actually I take that back - I want to be able to adjust the brightness quickly. But everything else is perfect Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340774 Share on other sites More sharing options...
xyph Posted April 26, 2012 Share Posted April 26, 2012 I don't want to do more with my iPhone than what it currently can do. I don't even use a lot of the features it has. Actually I take that back - I want to be able to adjust the brightness quickly. But everything else is perfect Jailbreak it. A JB app called SBSettings (I haven't used an iPhone since 3G, so there might be a newer app) allows you to slide your finger across the top infobar (with the battery life, singal etc on it). It then shows a popup that let's you change a bunch of configurations. One touch toggles for wifi/edge/3g etc, and a slider for brightness. Tons of other crap too. If they actually built and iPhone without the intention of abandoning it at most 1 year after it's release, I'd probably buy another. The fact that an iPhone 3GS could output sound in mono, but my 3G with the 'same' firmware couldn't was one of those breaking points for me. Listening to The Beatles, etc. with one ear-bud in sucks. Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340790 Share on other sites More sharing options...
Jessica Posted April 26, 2012 Share Posted April 26, 2012 I don't want to do more with my iPhone than what it currently can do. I don't even use a lot of the features it has. Actually I take that back - I want to be able to adjust the brightness quickly. But everything else is perfect Jailbreak it. A JB app called SBSettings (I haven't used an iPhone since 3G, so there might be a newer app) allows you to slide your finger across the top infobar (with the battery life, singal etc on it). It then shows a popup that let's you change a bunch of configurations. One touch toggles for wifi/edge/3g etc, and a slider for brightness. Tons of other crap too. Thanks, I'll check that out! Quote Link to comment https://forums.phpfreaks.com/topic/261595-formatting-surname/#findComment-1340795 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.