Редакция 2 | Только различия | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 2 | Редакция 116 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | /**
|
2 | /**
|
3 | * Smarty plugin
|
3 | * Smarty plugin
|
4 | * @package Smarty
|
4 | * @package Smarty
|
5 | * @subpackage plugins
|
5 | * @subpackage plugins
|
6 | */
|
6 | */
|
7 | 7 | ||
8 | 8 | ||
9 | /**
|
9 | /**
|
10 | * Smarty strip modifier plugin
|
10 | * Smarty strip modifier plugin
|
11 | *
|
11 | *
|
12 | * Type: modifier<br>
|
12 | * Type: modifier<br>
|
13 | * Name: strip<br>
|
13 | * Name: strip<br>
|
14 | * Purpose: Replace all repeated spaces, newlines, tabs
|
14 | * Purpose: Replace all repeated spaces, newlines, tabs
|
15 | * with a single space or supplied replacement string.<br>
|
15 | * with a single space or supplied replacement string.<br>
|
16 | * Example: {$var|strip} {$var|strip:" "}
|
16 | * Example: {$var|strip} {$var|strip:" "}
|
17 | * Date: September 25th, 2002
|
17 | * Date: September 25th, 2002
|
18 | * @link http://smarty.php.net/manual/en/language.modifier.strip.php
|
18 | * @link http://smarty.php.net/manual/en/language.modifier.strip.php
|
19 | * strip (Smarty online manual)
|
19 | * strip (Smarty online manual)
|
20 | * @author Monte Ohrt <monte at ohrt dot com>
|
20 | * @author Monte Ohrt <monte at ohrt dot com>
|
21 | * @version 1.0
|
21 | * @version 1.0
|
22 | * @param string
|
22 | * @param string
|
23 | * @param string
|
23 | * @param string
|
24 | * @return string
|
24 | * @return string
|
25 | */
|
25 | */
|
26 | function smarty_modifier_strip($text, $replace = ' ') |
26 | function smarty_modifier_strip($text, $replace = ' ') |
27 | {
|
27 | {
|
28 | return preg_replace('!\s+!', $replace, $text); |
28 | return preg_replace('!\s+!', $replace, $text); |
29 | }
|
29 | }
|
30 | 30 | ||
31 | /* vim: set expandtab: */
|
31 | /* vim: set expandtab: */
|
32 | 32 | ||
33 | ?>
|
33 | ?>
|
34 | 34 |