Training, Open Source computer languages

PerlPythonMySQLTclRubyC & C++LuaJavaTomcatPHPhttpdLinux

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Do not SHOUT and do not whisper
"Your Name" says a box on a form on our web page, and visitors who want to sign up duely enter their name. Some of the names are shouted - "GRAHAM ELLIS" - and others are whispered - "graham ellis" when really we would like them all nice and consistent and in regular case - for we're publishing a list of people who have signed up to support a cause.

It's tempting to convert all of the names to lower case and then capitalise the first letter of each word, but that would upset the MacGreggors and daVincis of this world (and Peter Rabbit learned not to get on the wrong side of Mr MacGreggor, I recall).

So ... if the web site visitor uses both upper case and lower case in his name, we'll assume he's got it right. But if he shouts or whispers, we'll convert it as I was originally tempted to do.

Here's the code for that, in PHP.

if (ereg('[A-Z][a-z]',$row[name])) {
  $names .= "$row[name]<br>";
} else {
  $names .= ucwords(strtolower($row[name]))."<br>";
}


And if you want to see some output from that, have a look here; to learn how to do it, have a look at our PHP course pages.
(written 2008-04-06 02:33:58)

 
Associated topics are indexed under
H107 - String Handling in PHP

Back to
Automating processes through Expect
Previous and next
or
Horse's mouth home
Forward to
M25 / South Mimms Service Area

Some other Articles
Learning to program in Perl
Sheep Shearers, Marathon Runners and Ocean Sailors
Learning and understanding scripting programming techniques
M25 / South Mimms Service Area
Do not SHOUT and do not whisper
Automating processes through Expect
Replacing the last comma with an and
Cambidge - Tcl, Expect and Perl courses
Fresher tutor, better course
Every link has two ends - fixing 404s at the recipient
1769 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 0800 043 8225 or 01225 708225 • FAX: 0845 8382 405 or 01225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho