note 97277 modified in function.ucfirst by danbrown
| From: | danbrown@php.net | Date: | Mon, 12 Apr 2010 14:59:59 +0000 |
| Subject: | note 97277 modified in function.ucfirst by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-168158@lists.php.net to get a copy of this message | ||
for anyone wanting to ucfirst each word in a sentence this works for me:
<?php
function ucfirst_sentence($str)
{
return preg_replace('/\b(\w)/e', 'strtoupper("$1")', $str);
}
?>
--was--
for anyone wanting to ucfirst each word in a sentence this works for me:
function ucfirst_sentence($str)
{
return preg_replace('/\b(\w)/e', 'strtoupper("$1")', $str);
}
http://php.net/manual/en/function.ucfirst.php