我有这样的数组
{
"sCode":"05",
"sCodeName":"critical_tight_connection",
"iSeverity":1,
"aData":{
"iLevelOfDetailt":2,
"iDuration":35,
"sLabel":"Labai trumpas pers\u0117dimas, 35 min.",
"sLink":""
}
}
我正在用 smarty 打印他(数组未序列化,我这样做是为了您的方便)
{if !empty( $aSegment.aNotices.aStop )}
<ul>
{foreach from=$aSegment.aNotices.aStop item=aNotice}
<li>
<img class="{$aNotice.sCodeName}" />
{$aNotice.sLabel}
</li>
{/foreach}
</ul>
{/if}
如果 aNotices.aStop.sCode 中存在 '05',如何使用 smarty 检查? (在 foreach 循环之前)
试过了
{if in_array('05', $aSegment.aNotices.aStop)}
exist
{/if}
最佳答案
你可以使用这个:
{if '05'|in_array:$aSegment.aNotices.aStop}EXIST{/if}
关于php - Smarty in_array 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14400460/