★ wanayoo — archive 1999 http://www.php.net/manual/ja/function.ucwords.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to 文字列
Quick Reference
English version of this pageGerman version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
文字列
* AddCSlashes
* AddSlashes
* bin2hex
* Chop
* Chr
* chunk_split
* convert_cyr_string
* count_chars
* crc32
* crypt
* echo
* explode
* flush
* get_html_translation_table
* get_meta_tags
* hebrev
* hebrevc
* htmlentities
* htmlspecialchars
* implode
* join
* levenshtein
* ltrim
* md5
* Metaphone
* nl2br
* ob_start
* ob_get_contents
* ob_end_flush
* ob_end_clean
* ob_implicit_flush
* Ord
* parse_str
* print
* printf
* quoted_printable_decode
* QuoteMeta
* rtrim
* sscanf
* setlocale
* similar_text
* soundex
* sprintf
* strcasecmp
* strchr
* strcmp
* strcspn
* strip_tags
* StripCSlashes
* StripSlashes
* stristr
* strlen
* str_pad
* strpos
* strrchr
* str_repeat
* strrev
* strrpos
* strspn
* strstr
* strtok
* strtolower
* strtoupper
* str_replace
* strtr
* substr
* substr_count
* substr_replace
* trim
* ucfirst
* ucwords
Manual: ucwords
View the source code for this pageSearch the site



Previous page
 ucfirst
 Updated
Mon, 14 Aug 2000
Sybase 
Next page


ucwords

(PHP3 >= 3.0.3, PHP4 )

ucwords --  文字列の各単語の最初の文字を大文字にする

説明

string ucwords (string str)

文字がアルファベットの場合、str の各単語の 最初の文字を大文字にします。

例 1. ucwords()の例


$text = "mary had a little lamb and she loved it so.";
$text = ucwords($text); // $textは「Mary Had A Little Lamb 
                        // And She Loved It So」になります。
      

strtoupper(), strtolower(),ucfirst() も参照下さい。


User Contributed Notes: ucwords


russ@cowboyz.com
24-Mar-2000 12:45
if string is all in uppercase, you must convert it to lower first; thusly: $iwant=ucwords(strtolower("THIS STRING IS ALL UPPERCASE")); . dunno why it doesn't check that- but there ya go, what ya gonna do?


bobo@ii.nl
17-Jul-2000 11:42
Mildly annoying, only spaces are considered whitespace by this function. So words right after linebreaks do not get capitalized. An explode/implode can help here.

$temp = explode ("\n", $capthis);
array_walk (&$temp, ucwords);
$capthis = implode ("\n", $temp);



Rodney_Hampton@yahoo.com
24-Jul-2000 11:20
I've had trouble with the ucwords command. I have found that the following is a reasonable substitute where crumb is the string that you want to make the words upper case.
<pre>
$nibble=explode (" ", $crumb);
$count=count($nibble);
$num=0;
while ($num<$count){
$nibble[$num]=ucfirst($nibble[$num]);
$num++;
}
$crumb=implode(" ",$nibble);
</pre>



chris.carlson@lats.com
28-Jul-2000 02:34
There are actually many cases where this routine doesn't work well. Any text preceeded by ( , " or - ; even text like T.G.I. which once converted to lower case then using ucwords you still end up with T.g.i. It would be nice if the routine would look at each word and ignore non-alphabetic characters as part of the word. Any other solution would be welcome.


 About Notes


Previous page
 ucfirst
 Updated
Mon, 14 Aug 2000
Sybase 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.