PageRenderTime 54ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/bblog/smarty_plugins/modifier.count_characters.php

https://github.com/escherlat/loquacity
PHP | 35 lines | 7 code | 6 blank | 22 comment | 1 complexity | b8580a6706647de0a26be2e84b600687 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /**
  3. * Smarty plugin
  4. *
  5. * @subpackage plugins
  6. * @package Smarty
  7. */
  8. /**
  9. * Smarty count_characters modifier plugin
  10. *
  11. * Type: modifier<br>
  12. * Name: count_characteres<br>
  13. * Purpose: count the number of characters in a text
  14. *
  15. * @link http://smarty.php.net/manual/en/language.modifier.count.characters.php
  16. * count_characters (Smarty online manual)
  17. * @param string
  18. * @param boolean include whitespace in the character count
  19. * @param unknown $string
  20. * @param unknown $include_spaces (optional)
  21. * @return integer
  22. */
  23. function smarty_modifier_count_characters($string, $include_spaces = false) {
  24. if ($include_spaces)
  25. return strlen($string);
  26. return preg_match_all("/[^\s]/", $string, $match);
  27. }
  28. /* vim: set expandtab: */
  29. ?>