modifier.strip.php 710 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * Smarty plugin
  4. *
  5. * @package Smarty
  6. * @subpackage PluginsModifier
  7. */
  8. /**
  9. * Smarty strip modifier plugin
  10. *
  11. * Type: modifier<br>
  12. * Name: strip<br>
  13. * Purpose: Replace all repeated spaces, newlines, tabs
  14. * with a single space or supplied replacement string.<br>
  15. * Example: {$var|strip} {$var|strip:"&nbsp;"}
  16. * Date: September 25th, 2002
  17. *
  18. * @link http://smarty.php.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
  19. * @author Monte Ohrt <monte at ohrt dot com>
  20. * @version 1.0
  21. * @param string $
  22. * @param string $
  23. * @return string
  24. */
  25. function smarty_modifier_strip($text, $replace = ' ')
  26. {
  27. return preg_replace('!\s+!', $replace, $text);
  28. }
  29. ?>