adding some strings
[moodle-linuxchix.git] / lib / smarty / plugins / modifier.capitalize.php
blob2b9169cefa67b6ec415950c5ea68f94c0133c161
1 <?php
2 /**
3 * Smarty plugin
4 * @package Smarty
5 * @subpackage plugins
6 */
9 /**
10 * Smarty capitalize modifier plugin
12 * Type: modifier<br>
13 * Name: capitalize<br>
14 * Purpose: capitalize words in the string
15 * @link http://smarty.php.net/manual/en/language.modifiers.php#LANGUAGE.MODIFIER.CAPITALIZE
16 * capitalize (Smarty online manual)
17 * @param string
18 * @return string
20 function smarty_modifier_capitalize($string, $uc_digits = false)
22 smarty_modifier_capitalize_ucfirst(null, $uc_digits);
23 return preg_replace_callback('!\b\w+\b!', 'smarty_modifier_capitalize_ucfirst', $string);
26 function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null)
28 static $_uc_digits = false;
30 if(isset($uc_digits)) {
31 $_uc_digits = $uc_digits;
32 return;
35 if(!preg_match('!\d!',$string[0]) || $_uc_digits)
36 return ucfirst($string[0]);
37 else
38 return $string[0];