繁体   English   中英

在PHP / Smarty-Template中检查与正则表达式匹配的字符串

[英]Check string matching with regular expression within PHP/Smarty-Template

我想检查是否在查询中是否在字符串中出现特定字符串(WBT)并对其作出响应。 我知道可以在Smarty模板中使用正则表达式,但是文档中的建议尚不清楚。

这是我需要正则表达式检查其中是否出现字符串WBT的代码:

<div class="card-content" style="text-align: center;">
   [{if $woche.lehrskript}] // Check if "WBT" occurs in the string lehrskript
     <strong>WBT</string>
   [{else}]
     <strong>[{$woche.lehrskript.name}]</strong>
   [{/if}]
</div>

有人能帮助我吗?

我已经这样解决了:

[{if strpos($woche.lehrskript.name, 'WBT') != false}]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM