modifier.spacify.php 736 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * Smarty plugin
  4. * @package Smarty
  5. * @subpackage PluginsModifier
  6. */
  7. /**
  8. * Smarty spacify modifier plugin
  9. *
  10. * Type: modifier<br>
  11. * Name: spacify<br>
  12. * Purpose: add spaces between characters in a string
  13. *
  14. * @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
  15. * @author Monte Ohrt <monte at ohrt dot com>
  16. * @param string $string input string
  17. * @param string $spacify_char string to insert between characters.
  18. * @return string
  19. */
  20. function smarty_modifier_spacify($string, $spacify_char = ' ')
  21. {
  22. // well… what about charsets besides latin and UTF-8?
  23. return implode($spacify_char, preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY));
  24. }
  25. ?>