473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

uppercase surname with apostrophe in php

Hi Friends, I am Anes
I want to ensure all surnames are uppercase in php
I use $surname = ucfirst(strtolower($dataField));

How do I ensure that any names such as O'Brien, don't result in O'brien

thanks
Nov 6 '10 #1
2 2589
hsriat
1,654 Expert 1GB
Try this ...
Expand|Select|Wrap|Line Numbers
  1. $surname = preg_replace(ucfirst(strtolower($dataField)), "/\'([a-z]{1})/i", ucfirst("$1"));
Nov 6 '10 #2
Markus
6,050 Expert 4TB
If I were you, I wouldn't worry about this. There are many cases in which you'd need a separate algorithm to properly case the names. The smart thing to do would be have the user enter their name as they would like it to appear.
Nov 7 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: Hallvard B Furuseth | last post by:
Has someone got a Python routine or module which converts Unicode strings to lowercase (or uppercase)? What I actually need to do is to compare a number of strings in a case-insensitive manner,...
1
by: news | last post by:
Hi there, I have a table in an Oracle 9i R2 database containing the following string" "It's so easy" When I try to execute the following query: SELECT EXPRESSION FROM EXPRESSIONS WHERE...
2
by: Michael Sterling | last post by:
i'm using delphi 7 and have a query in which i'm trying to find names that have an apostrophe in them, i.e. "o'mally". my problem is that when i write my select statement i can't get the quotes...
3
by: R.Georges | last post by:
Hi, Someone knows if while matching a set of node for a namespace-uri, I must ignore lowercase/uppercase. For instance, I search "http://www.w3.org/1999/XSL/Transfrom" namespace node inside...
13
by: Richard Hollenbeck | last post by:
To prevent future apostrophe bugs and errors, isn't it just simpler to forbid an apostrophe from being entered into a text field? For example, couldn't "Alice's Restaurant" be changed to "Alices...
1
by: congngo | last post by:
Hi all Every time I export a table into an excel spreadsheet. It has a leading apostrophe on every cells. This drive me nut. I have to do a work around by export table into a txt file than...
1
by: geodev | last post by:
I’m copying data across from an Access database to an MSDE database through the use of some vb.net code. Unfortunately the application crashes when it goes to copy across data, in particular...
1
by: Rose | last post by:
Hi all, I'm trying to create a clickable link, but the pesky apostrophe is preventing the link from getting displayed properly. I'm displaying the contents of a folder (with contains the...
3
by: dave k | last post by:
I often use the Control and Apostrophe keys to enter the value from the same field of the previous record in a form. I would prefer to use a mouse and the double click function. Can anyone help...
9
by: Thomas 'PointedEars' Lahn | last post by:
Jukka K. Korpela wrote: IBTD. For example, in English it is customary (and AIUI expected) to use the character that ’ represents should be used to delimit a quotation within direct speech...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.