Smarty模板引擎,如何检查字符串是否以模板中的子字符串结尾

问题描述 投票:0回答:1

如何检查字符串是否以smarty3模板中的子字符串结尾?

就像是:

{if string|ends_with:substring}
    String realy ends with substring
{/if}
php templates smarty template-engine smarty3
1个回答
0
投票

你可以使用php substr:

{if ($string|substr:N:M) == "wantedSubstring"}
    ...
{/if}

其中N和M是子串的索引。

检查substr手册的语法。

© www.soinside.com 2019 - 2024. All rights reserved.