note 105526 added to function.ucwords
| From: | gabe at fijiwebdesign dot com | Date: | Wed, 24 Aug 2011 18:49:15 +0000 |
| Subject: | note 105526 added to function.ucwords | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-182707@lists.php.net to get a copy of this message | ||
Another ucwords function with custom separator.
<?php
function ucwords_custom($str, $sep)
{
return preg_replace_callback('/' . preg_quote($sep) . './i',
create_function(
'$match',
'return strtoupper($match[0][1]);'
), $str);
}
?>
or simpler with PHP5.3
<?php
function ucwords_custom2($str, $sep = ' ')
{
return preg_replace_callback('/' . preg_quote($sep) . './i',
function($match) {
return strtoupper($match[0][1]);
}, $str);
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 192.195.66.2
----
Manual Page -- http://www.php.net/manual/en/function.ucwords.php
Edit -- https://master.php.net/note/edit/105526
Del: integrated -- https://master.php.net/note/delete/105526/integrated
Del: useless -- https://master.php.net/note/delete/105526/useless
Del: bad code -- https://master.php.net/note/delete/105526/bad+code
Del: spam -- https://master.php.net/note/delete/105526/spam
Del: non-english -- https://master.php.net/note/delete/105526/non-english
Del: in docs -- https://master.php.net/note/delete/105526/in+docs
Del: other reasons-- https://master.php.net/note/delete/105526
Reject -- https://master.php.net/note/reject/105526
Search -- https://master.php.net/manage/user-notes.php