TPLix

No results for ""

Replace

2 min read Jun 2, 2026
--- title: replace autoseo: enabled: true theme: learn2 child_type: default admin: children_display_order: collection visible: true ---

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

Leave a Comment

Not published. Used to notify you on approval.

Comments are moderated before appearing.