array_key_exists() in template

tenants

Well-known member
Inside templates, we have a way to check if values exist:

Code:
 <xen:if is="in_array({$visitor.user_id}, array('1', '2', '3'))">your id is 1 2 or 3 ...</xen:if>

but to find if an array key exists is there a similar way?

I guess usually you could use:

<xen:if is="{$someVaraible.myKey}"> this key this exists </xen:if>

But in my case, I need to check if an ip exists in a key, obviously in this case the above wont work, since the key contains decimals:

{$someVaraible.127.0.0.1}

currently I'm thinking of looping to check:
Code:
   <xen:foreach loop="$someVaraible.myKey" key="$botIp" value="$botTime">
      <xen:if is="{$botIp}=='127.0.0.1'">Yay, I found my key</xen:if>
   </xen:foreach>

Is there a better (performing and cleaner) way to check to see if this key exists (it's been a while since I've looked at xen template coding, so I'm a bit rusty).

I was hoping something like this might work:

<xen:if is="{$someVaraible['myKey']}">
 
Top Bottom