Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
array as parameter for modifying variable

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
SunWuKung
Smarty Rookie


Joined: 20 Sep 2008
Posts: 20

PostPosted: Sat May 23, 2009 11:38 am    Post subject: array as parameter for modifying variable Reply with quote

I would like to do multiple replacement on a variable.
The documentation says that smarty replace acts like php replace but it only gives the syntax for scalars: {$articleTitle|replace:'Garden':'Vineyard'}

How do I do the same with arrays, like this?
{$phrase|replace:array("fruits", "vegetables", "fiber"):array("pizza", "beer", "ice cream")}

Thanks for the help.
SWK
Back to top
View user's profile Send private message
SunWuKung
Smarty Rookie


Joined: 20 Sep 2008
Posts: 20

PostPosted: Mon May 25, 2009 7:31 am    Post subject: solved Reply with quote

I found it using the set plugin.

{set var=$find value=array('aaa', 'bbb')}
{set var=$replace value=array('raaa', 'rbbb')}

{$document|replace:$find:$replace}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP