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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: pulstar at mail dot com
New email:
PHP Version: OS:

 

 [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 Mar 29 02:01:30 2024 UTC