smarty的foreach判断键值存不存在

如题所述

1, 用count来取得数组的下标个数
下面例子中,如果$array为空则不输出任何数据
以下为引用的内容:
{if $array|@count neq 0 }
...
{/if}

2, 直接判断

以下为引用的内容:

{if $array neq "" }
...
{/if}

3, 另外介绍(Smarty中如何判断一个变量是字符串还是数组)
{if isset($name) && $name == 'Blog'}
{* do something *}
{elseif $name == $foo}
{* do something *}
{/if}

{if is_array($foo) && count($foo) > 0)
{* do a foreach loop *}
{/if}

smarty逻辑运算符

eq equal : 相等

neq not equal:不等于

gt greater than:大于

lt less than:小于

lte less than or equal:小于等于

gte great than or equal:大于等于

is even:是偶数

is odd:是奇数

is not even:不是偶数

is not odd不是奇数

not:非

mod:取余

div by:被。。。除
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网