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 开发者_如何学JAVAtried 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?
This is the way str_replace in Smarty works:
{"replace_this_text"|str_replace:"I am the new text":$value}
General, Smarty's pipe '|' operator use the value before the pipe as the first argument for the called function, which is the search text in case of str_replace.
You want to use a modifier:
{$v.data|regex_replace:"/^\d+,/":""}
精彩评论