1, using Count to get the subscript number of the array
In the following example, if $array is empty, no data is output
The following are the referenced contents:
The code is as follows |
Copy Code |
{if $array | @count neq 0} <br> {/if} |
2, direct judgment
The following are the referenced contents:
The code is as follows |
Copy Code |
{if $array neq ""} <br> {/if} |
1, using Count to get the subscript number of the array
In the following example, if $array is empty, no data is output
The following are the referenced contents:
The code is as follows |
Copy Code |
{if $array | @count neq 0} <br> {/if} |
2, direct judgment
The following are the referenced contents:
The code is as follows |
Copy Code |
{if $array neq ""} <br> {/if} |
Another introduction
How to determine whether a variable is a string or an array in Smarty
The code is as follows |
Copy Code |
{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} |