Mozilla/mozilla/webtools/addons/lib/smarty/libs/plugins/modifier.count_characters.php
mike.morgan%oregonstate.edu b84b30bd83 Initial checkin of AMO v2.0 framework.
Notes:
    index.php - example document for main index, default.tpl wrapper
    faq.php - example document for faq page, nonav.tpl wrapper


git-svn-id: svn://10.0.0.236/trunk@175939 18797224-902f-48f8-a5cc-f745e15eee43
2005-07-11 23:52:20 +00:00

32 lines
695 B
PHP

<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty count_characters modifier plugin
*
* Type: modifier<br>
* Name: count_characteres<br>
* Purpose: count the number of characters in a text
* @link http://smarty.php.net/manual/en/language.modifier.count.characters.php
* count_characters (Smarty online manual)
* @param string
* @param boolean include whitespace in the character count
* @return integer
*/
function smarty_modifier_count_characters($string, $include_spaces = false)
{
if ($include_spaces)
return(strlen($string));
return preg_match_all("/[^\s]/",$string, $match);
}
/* vim: set expandtab: */
?>