Home > Backend Development > PHP Tutorial > smarty模板判断数组为空的方法_php实例

smarty模板判断数组为空的方法_php实例

WBOY
Release: 2016-06-07 17:12:39
Original
1067 people have browsed it

本文实例讲述了smarty模板判断数组为空的方法。分享给大家供大家参考。具体如下:

这里主要介绍两种方法:

1. 用count来取得数组的下标个数

下面例子中,如果$array为空则不输出任何数据

{if $array|@count neq 0 }
// array is empty
{/if}

Copy after login

2. 直接判断

{ if $array neq ""}
//array is empty
{/if}
Copy after login

希望本文所述对大家基于smarty模板的php程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template