使用str_replace和smarty变量

zx.*_*zx. 1 php smarty

基本上我只想删除一部分我聪明的变量内容.

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

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

{$v.data}

{/if}

{/foreach}
Run Code Online (Sandbox Code Playgroud)

{$v.data} 将呼出21,5555555555

我希望它只能回显5555555555.我试过str_replace但是无法让它工作..

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

str_replace('"','',$v.data);// - doesn't work
Run Code Online (Sandbox Code Playgroud)

什么是我能做到这一点的最好方法?

小智 6

这是Smarty中str_replace的工作方式:

{"replace_this_text"|str_replace:"I am the new text":$value}
Run Code Online (Sandbox Code Playgroud)

将军,Smarty的烟斗'|' 运算符使用管道前的值作为被调用函数的第一个参数,这是str_replace的搜索文本.