Smarty in_array value
31,418
Solution 1
you can use this :
{if '05'|in_array:$aSegment.aNotices.aStop}EXIST{/if}
Solution 2
Do you mean something like this?
{if $aNotice.sCode == '05'} ....
Author by
Itsmeromka
I ll code my own world, with blackjack and .. you know!
Updated on August 04, 2022Comments
-
Itsmeromka almost 2 years
I have array like this
{ "sCode":"05", "sCodeName":"critical_tight_connection", "iSeverity":1, "aData":{ "iLevelOfDetailt":2, "iDuration":35, "sLabel":"Labai trumpas pers\u0117dimas, 35 min.", "sLink":"" } }
i am printing him with smarty (array is not serialized, i ve did it for your с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}
how to check with smarty if '05' is exist in aNotices.aStop.sCode ? (before foreach cycle)
Tried this
{if in_array('05', $aSegment.aNotices.aStop)} exist {/if}
-
Ron van der Heijden over 11 yearsMaybe
{php}
and{/php}
around the if statement helps. -
Prisoner over 11 years@Bondye no, that is not right.
-
-
michalzuber about 8 yearsWorked like charm
{if $smarty.session.user.group|in_array:['admin','broker']}