Replace
replace — A simple search and replace on a variable. This is equivalent to the PHP's str_replace() function.
<?php
$tplix->assign('articleTitle',
"Hello World!, Today name is yesterday"
);
Although Tplix supplies this replace convenience modifier, it is usually better to apply string or array.
Basic Usage:
{$articleTitle|replace:"yesterday":"monday"}
Parameters:| Parameter | Type | Required | Description |
|---|---|---|---|
| 1 | string/array | Yes | This is the string or array of text to be replaced. |
| 2 | string/array | Yes | This is the string or array of text to replace with. |
Where the template is:
//simple display
{$articleTitle}
//signle word or chr replacement
{$articleTitle|replace:"yesterday":"monday"}
//multiple word or chrs replacement
{$articleTitle|replace:['yesterday','is']:['monday','was']}
Output:
Hello World!, Today name is yesterday
Hello World!, Today name is monday
Hello World!, Today name was monday