我有这样的数组
{
"sCode":"05",
"sCodeName":"critical_tight_connection",
"iSeverity":1,
"aData":{
"iLevelOfDetailt":2,
"iDuration":35,
"sLabel":"Labai trumpas pers\u0117dimas, 35 min.",
"sLink":""
}
}
Run Code Online (Sandbox Code Playgroud)
我用smarty打印他(阵列没有序列化,我已经为你的сonveniece做了)
{if !empty( $aSegment.aNotices.aStop )}
<ul>
{foreach from=$aSegment.aNotices.aStop item=aNotice}
<li>
<img class="{$aNotice.sCodeName}" />
{$aNotice.sLabel}
</li>
{/foreach}
</ul>
{/if}
Run Code Online (Sandbox Code Playgroud)
如果aNotices.aStop.sCode中存在'05',如何用smarty检查?(在foreach周期之前)
试过这个
{if in_array('05', $aSegment.aNotices.aStop)}
exist
{/if}
Run Code Online (Sandbox Code Playgroud)
Jef*_*Bic 17
你可以用这个:
{if '05'|in_array:$aSegment.aNotices.aStop}EXIST{/if}
Run Code Online (Sandbox Code Playgroud)