I have fname and lname in my database, and a name could be stored as JOHN DOE or john DOE or JoHN dOE, but ultimately I want to display it as John Doe
fname being John and lname being Doe
Be aware that there are other capitalisation formats, such as John McDoe, John D'Oe, John de O, and John van den Doe.
seeing it is tagged PHP:
either
string ucfirst ( string $str );
to uppercase first letter of the first word
or
string ucwords ( string $str );
to uppercase the first letter of every word
you might want to use those in combination with
string strtolower ( string $str );
to normalize all names to lower case first.
I'm not sure where and how you want to display it, but if it's on a web-page you might try simply altering the display using CSS. Try adding:
text-transform:capitalize;
to the relevant rule, like this:
.name { text-transform:capitalize;}
if you put the name in a div or span with class="name". Of course, this will not in any way alter the database entry, but I wasn't clear which was preferable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With