php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #14412 ucwords() new parameter
Submitted: 2001-12-10 16:07 UTC Modified: 2015-01-08 22:25 UTC
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: pulstar at mail dot com Assigned:
Status: Wont fix Package: Strings related
PHP Version: 4.0.6 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
50 - 23 = ?
Subscribe to this entry?

 
 [2001-12-10 16:07 UTC] pulstar at mail dot com
Ucwords() should have an optional parameter to set the minimum of characters a word must have to be capitalized. For example, sometimes I don't want to capitalize words with less than 3 characters. Examples:

New York Institute Of Photography
New York Institute of Photography (better)

My Web Site Is Cool With PHP
My Web Site is Cool With PHP (better)

Well, may the first word be capitalized by ucwords() even if its size is less than specified by the parameter? In any case we can capitalize it with ucfirst().  :-)

$str=ucfirst(ucwords(strtolower($str),3));

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-01 00:15 UTC] jani@php.net
-Package: Feature/Change Request +Package: Strings related
 [2015-01-08 22:25 UTC] ajf@php.net
-Status: Open +Status: Wont fix
 [2015-01-08 22:25 UTC] ajf@php.net
This seems prone to not working properly. There are 3- and 4-character English words which shouldn't be uppercased. It's been 13 years and I doubt this'll be done.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 06:01:32 2024 UTC