943,607 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1638
  • PHP RSS
Jan 24th, 2009
0

Dispaly Each First character is capital ??

Expand Post »
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??
Last edited by Aamit; Jan 24th, 2009 at 9:49 am.
Reputation Points: 3
Solved Threads: 15
Posting Whiz
Aamit is offline Offline
341 posts
since Apr 2008
Jan 24th, 2009
0

Re: Dispaly Each First character is capital ??

Reputation Points: 10
Solved Threads: 1
Newbie Poster
Yayo_SK is offline Offline
11 posts
since Jan 2009
Jan 24th, 2009
0

Re: Dispaly Each First character is capital ??

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 Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. $str="DAniweb it DISCUSSION Community"
  4. $str = strtolower($str);
  5. $str = ucwords($str);
  6.  
  7. ?>

or

PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. $str ="DAniweb it DISCUSSION Community"
  4. $str = ucwords(strtolower($str));
  5. ?>
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
Andrieux is offline Offline
60 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: HTML to PDF and print
Next Thread in PHP Forum Timeline: OOP Problem, help me?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC