php 在 smarty 中打破/爆炸字符串

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8355745/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 04:30:28  来源:igfitidea点击:

Break/explode String in smarty

phpsmarty

提问by temp-learn

can some 1 tell how to break this sort of String in smarty what i want is "1" as price and "dollar" as currency type.

有人能告诉我如何在 smarty 中打破这种字符串,我想要的是“1”作为价格和“美元”作为货币类型。

"1|dollar"

please reply.

请回复。

回答by Jan Han?i?

You could do something like this:

你可以这样做:

{assign var=someVar value="|"|explode:"1|dollar"}

and then access "1" and "dollar" through 0 and 1 indexes of the "someVar" variable like below,

然后通过“someVar”变量的0和1索引访问“1”和“美元”,如下所示,

{$somevar[0]}and {$somevar[1]}

{$somevar[0]}{$somevar[1]}