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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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-2019 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 02:01:25 2019 UTC