mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
implement optional param to capitalize for digit behavior
This commit is contained in:
@@ -17,14 +17,15 @@
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_capitalize($string)
|
||||
function smarty_modifier_capitalize($string, $uc_digits = false)
|
||||
{
|
||||
define('SMARTY_CAPITALIZE_UCDIGIT', $uc_digits);
|
||||
return preg_replace_callback('!\b\w+\b!', 'smarty_modifier_capitalize_ucfirst', $string);
|
||||
}
|
||||
|
||||
function smarty_modifier_capitalize_ucfirst($string)
|
||||
{
|
||||
if(!preg_match('!\d!',$string[0]))
|
||||
if(!preg_match('!\d!',$string[0]) || SMARTY_CAPITALIZE_UCDIGIT)
|
||||
return ucfirst($string[0]);
|
||||
else
|
||||
return $string[0];
|
||||
|
Reference in New Issue
Block a user