Jump to content

Archived

This topic is now archived and is closed to further replies.

rwwd

string conversion

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--]

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.