954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Dispaly Each First character is capital ??

Hi,

In my $str="DAniweb it DISCUSSION Community"
I want "Each First" character is capital and rest of lower case "

If String is
$str="DAniweb it DISCUSSION Community"

Ans-> Daniweb It Discussion Community

How to do this??

Aamit
Posting Whiz
342 posts since Apr 2008
Reputation Points: 3
Solved Threads: 15
 
Yayo_SK
Newbie Poster
11 posts since Jan 2009
Reputation Points: 10
Solved Threads: 1
 

Yayo, that'd output:

"DAniweb It DISCUSSION Community"

You need to use strtolower(), and ucwords(). strtolower() makes all characters in a string lowercase; ucwords() capitalizes the first letter of each word in a string.

<?php

$str="DAniweb it DISCUSSION Community"
$str = strtolower($str);
$str = ucwords($str);

?>


or

<?php

$str ="DAniweb it DISCUSSION Community"
$str = ucwords(strtolower($str));
?>
Andrieux
Junior Poster in Training
61 posts since Jan 2009
Reputation Points: 10
Solved Threads: 4
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You