How to use str_replace in Smarty
html, php, smarty
Solution
You can use PHP functions as Smarty modifiers, but Smarty has a built-in `replace` modifier. Use it like this:
<{foreach item=list key=num from=$product}>
<li><a href="<{$config.weburl}>/<{$list.somename|replace:' ':'_'}>"><{$list.somename}></a></li>
<{/foreach}>
Problem
I'm using PHP smarty to declare a link : ``` <{foreach item=list key=num from=$product}> <li><a href="<{$config.weburl}>/<{$list.somename}>"><{$list.somename}></a></li> <{/foreach}>` ``` and the resulting link when mouseover is : ``` "http:/domain/some name" ``` I need to str_replace the space char (some name) with an underscore (some_name), how to do that?? like result below : ``` "http:/domain/some_name" ``` I'm using the following code but it does not work. How to use str_replace with an array in html? ``` <a href="<{$config.weburl}>/'.str_replace(array(' ','%'),array('_','-'),<{$list.somename}>).'"> ```