Jump to content

Recommended Posts

[!--fonto:Verdana--][span style=\"font-family:Verdana\"][!--/fonto--]
Hello there everybody,

Silly thing to ask but say you have a string ie: timothy, and you wanted this to become first letter uppercase ie: Timothy, how would I do this, so that every time you have a string in a variable the first letter displayed would be uppercase every time?

Any help is appreciated

Thanks
Rwwd
[!--fontc--][/span][!--/fontc--]
Link to comment
https://forums.phpfreaks.com/topic/5500-string-conversion/
Share on other sites

There is the function [a href=\"http://www.php.net/ucwords\" target=\"_blank\"]ucwords[/a]() which will make each word in a string start with a capital letter. Is this what you are looking for?

You can also use CSS.

[code]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
    <title></title>
    <style>
.initc {
    text-transform: capitalize;
}    
    </style>
</head>

<body>
<p class="initc">this is a test</p>
<p><?php echo ucwords('this is another test') ?></p>

</body>
</html>
[/code]

Ken
Link to comment
https://forums.phpfreaks.com/topic/5500-string-conversion/#findComment-19668
Share on other sites

Hi there Ken,

Thanks for the help, I didnt realise as you could do this in css aswell as php, in the end i settled for the ucfirst(), which served the purpose perfectly, but you have given me an idea for my next project.

Again thanks for the help


RWWD.
Link to comment
https://forums.phpfreaks.com/topic/5500-string-conversion/#findComment-21329
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.