Search code examples
phpsmarty

Using str_replace with smarty variable


Basically I just want to strip out a part of my smarty variable contents.

{foreach from=$_sequences key=k item=v}

{if $v.pri == $smarty.get.cf && $v.type == 'TTS'}

{$v.data}

{/if}

{/foreach}

{$v.data} will echo out 21,5555555555

I want it to only echo out 5555555555. I tried str_replace but couldn't get it working..

str_replace('"','',${v.data});//   - doesn't work

str_replace('"','',$v.data);// - doesn't work

What would be the best way I can accomplish this?


Solution

  • You want to use a modifier:

    {$v.data|regex_replace:"/^\d+,/":""}