在smarty中,如何检查关联数组是否为空?

PHP*_*ver 2 php smarty

我为它做了谷歌,但无法获得正确的解决方案。谁能帮我检查关联数组是否为空。提前致谢。

Mar*_*lte 5

在Smarty3中,您可以使用PHP的empty()函数

somefile.php

<?PHP
$smarty->assign('array',array());
$smarty->display('template.tpl');
Run Code Online (Sandbox Code Playgroud)

template.tpl

{if empty($array)}
  Array is empty
{else}
  Array is not not empty
{/if}
Run Code Online (Sandbox Code Playgroud)

输出Array is empty