[英]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.