Dispaly Each First character is capital ??

Reply

Join Date: Apr 2008
Posts: 296
Reputation: Aamit has a little shameless behaviour in the past 
Solved Threads: 11
Aamit Aamit is offline Offline
Posting Whiz in Training

Dispaly Each First character is capital ??

 
0
  #1
Jan 24th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 11
Reputation: Yayo_SK is an unknown quantity at this point 
Solved Threads: 1
Yayo_SK Yayo_SK is offline Offline
Newbie Poster

Re: Dispaly Each First character is capital ??

 
0
  #2
Jan 24th, 2009
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 61
Reputation: Andrieux is an unknown quantity at this point 
Solved Threads: 4
Andrieux Andrieux is offline Offline
Junior Poster in Training

Re: Dispaly Each First character is capital ??

 
0
  #3
Jan 24th, 2009
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.
  1. <?php
  2.  
  3. $str="DAniweb it DISCUSSION Community"
  4. $str = strtolower($str);
  5. $str = ucwords($str);
  6.  
  7. ?>

or

  1. <?php
  2.  
  3. $str ="DAniweb it DISCUSSION Community"
  4. $str = ucwords(strtolower($str));
  5. ?>
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum


Views: 936 | Replies: 2
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC