Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
991 lars 1
# replace
148 lars 2
 
3
A simple search and replace on a variable. This is equivalent to the
991 lars 4
PHP's [`str_replace()`](https://www.php.net/str_replace) function.
148 lars 5
 
991 lars 6
## Basic usage
7
```smarty
8
{$myVar|replace:"foo":"bar"}
9
```
148 lars 10
 
991 lars 11
## Parameters
148 lars 12
 
991 lars 13
| Parameter Position | Type   | Required | Description                                 |
14
|--------------------|--------|----------|---------------------------------------------|
15
| 1                  | string | Yes      | This is the string of text to be replaced.  |
16
| 2                  | string | Yes      | This is the string of text to replace with. |
148 lars 17
 
18
 
991 lars 19
## Examples
148 lars 20
 
991 lars 21
```php
22
<?php
148 lars 23
 
991 lars 24
$smarty->assign('articleTitle', "Child's Stool Great for Use in Garden.");
148 lars 25
 
991 lars 26
```
148 lars 27
 
991 lars 28
Where template is:
148 lars 29
 
991 lars 30
```smarty
31
{$articleTitle}
32
{$articleTitle|replace:'Garden':'Vineyard'}
33
{$articleTitle|replace:' ':'   '}
34
```
148 lars 35
 
36
Will output:
37
 
991 lars 38
```
39
Child's Stool Great for Use in Garden.
40
Child's Stool Great for Use in Vineyard.
41
Child's   Stool   Great   for   Use   in   Garden.
42
```
148 lars 43
 
991 lars 44
See also [`regex_replace`](language-modifier-regex-replace.md) and
45
[`escape`](language-modifier-escape.md).