Jump to content


Photo

string conversion


  • Please log in to reply
2 replies to this topic

#1 rwwd

rwwd
  • Members
  • PipPipPip
  • Advanced Member
  • 385 posts
  • LocationOn here sometimes

Posted 22 March 2006 - 02:28 PM

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

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 22 March 2006 - 03:14 PM

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.

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

Ken

#3 rwwd

rwwd
  • Members
  • PipPipPip
  • Advanced Member
  • 385 posts
  • LocationOn here sometimes

Posted 27 March 2006 - 08:53 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users