Closed s2b closed 5 months ago
The ReplaceViewHelper replaces one or multiple strings with other strings. This ViewHelper mimicks PHP's :php:str_replace() function. However, it's also possible to provide replace pairs as associative array via the "replace" argument.
str_replace()
Replace a single string:
<f:replace value="Hello World" search="World" replace="Fluid" /> <!-- Output: Hello Fluid -->
Replace multiple strings:
<f:replace value="Hello World" search="{0: 'World', 1: 'Hello'}" replace="{0: 'Fluid', 1: 'Hi'}" /> <!-- Output: Hi Fluid -->
Replace multiple strings using associative array:
<f:replace value="Hello World" replace="{'World': 'Fluid', 'Hello': 'Hi'}" /> <!-- Output: Hi Fluid -->
The ReplaceViewHelper replaces one or multiple strings with other strings. This ViewHelper mimicks PHP's :php:
str_replace()
function. However, it's also possible to provide replace pairs as associative array via the "replace" argument.Replace a single string:
Replace multiple strings:
Replace multiple strings using associative array: