note 59367 deleted from function.ucwords by cmb
| From: | cmb@php.net | Date: | Tue, 05 Nov 2019 14:51:01 +0000 |
| Subject: | note 59367 deleted from function.ucwords by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212947@lists.php.net to get a copy of this message | ||
Note Submitter: ieure at php dot net
----
Whoa guys, tone things down a bit here. No need to loop and implode. This is a one-line solution:
function ucsmart($text)
{
return preg_replace('/([^a-z]|^)([a-z])/e',
'"$1".strtoupper("$2")',
strtolower($text));
}
igua's code adds a backslash in front of the first single quote for me. This doesn't alter
the content in any way other than changing case.