今天在做一个数组遍历时会碰到数组中包含有数组了,但数组中包含的不一定有数组所以我们需要加以判断,下面我总结了一些方法。
php程序如下
- $aList['xx']['house_sell'] = array('a','b','c');
- smarty 模板中做法
- <!--{if is_array($item.house_sell)}-->
- <!--{/if}-->
补充其它办法
{if $array|@count neq 0 }
... ...
{/if}
或
{ if $array neq ""}
......
{/if}
或
<!--{if count($member_logo) neq 0}-->
<!--{/if}-->
注意:后面三种判断是不是数组我没有测试过哦,大家可测试一下吧