Re: note 93647 added to function.ucwords
| From: | Lars Torben Wilson | Date: | Mon, 21 Sep 2009 09:17:17 +0000 |
| Subject: | Re: note 93647 added to function.ucwords | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160879@lists.php.net to get a copy of this message | ||
On Mon, 21 Sep 2009 02:18:24 -0700
info@itestense.it wrote:
> I needed to capitalize the first word ad a string, so I wrote this
> simple function
>
> <?php
> function capitalize_first_word($str){
> $arr = explode(" ",$str,2);
> $arr[0] = strtoupper($arr[0]);
> $str = implode(" ",$arr);
> return $str;
> }
> ?>
Just wanted to send this to let you know that I'm deleting this note
because ucfirst(), which has been a standard PHP function for many
years, does this much more efficiently.
Regards,
Torben
> Hope it helps.
> ----
> Server IP: 208.69.120.35
> Probable Submitter: 95.224.131.152
> ----
> Manual Page --
> http://www.php.net/manual/en/function.ucwords.php
> Edit -- https://master.php.net/note/edit/93647
> Del: integrated --
> https://master.php.net/note/delete/93647/integrated Del:
> useless
> -- https://master.php.net/note/delete/93647/useless Del: bad
> code
> -- https://master.php.net/note/delete/93647/bad+code Del: spam
> -- https://master.php.net/note/delete/93647/spam Del:
> non-english --
> https://master.php.net/note/delete/93647/non-english Del: in
> docs
> -- https://master.php.net/note/delete/93647/in+docs Del: other
> reasons-- https://master.php.net/note/delete/93647 Reject
> --
> https://master.php.net/note/reject/93647 Search --
> https://master.php.net/manage/user-notes.php
>
>