我对Smarty不太熟悉。
我想知道如何从给定的字符串中删除所有空格字符?
我有一个字符串,像这样“this is my string”。 输出应该是“thisismystring”。
我该怎么做?
{$variable|replace:' ':''}
根据文档:
{$YourVariable|replace:' ':''}
如果在strip中间有任何内容,所有的空格都会被移除。
{strip}{/strip}
您可以使用 strip modifier 从变量(字符串)中删除空格,并将空字符串作为参数传递给它:
strip
{$myVar|strip:""}
{$variable|replace:' ':''}
。 - DCoder