Re: [SMARTY] testing if array has elements
| From: | Andreas Goetz | Date: | Fri, 01 Oct 2004 11:25:08 +0000 |
| Subject: | Re: [SMARTY] testing if array has elements | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11843@lists.php.net to get a copy of this message | ||
Not really- it still evaluates to true (always). Compiled template is:
<?php if (count ( $this->_tpl_vars['video']['country'] ) > 0):
?>
<tr><td><b><?php echo
$this->_tpl_vars['lang']['country']; ?>
:</b></td>
<td>
<?php if (count($_from =
(array)$this->_tpl_vars['video']['country'])):
foreach ($_from as $this->_tpl_vars['country']):
?>
The last part is produced by the {foreach}, the first count call is from {if
count($video.country) > 0}
Any ideas?
Thanks,
Andi
"Thorsten Suckow-Homberg" <ts@siteartwork.de> wrote in message
news:00ab01c4a7a8$58f063b0$0100a8c0@gandalf...
> >I need to test if an array has elements, FAQ says to use $array|@count.
> >Now my array is contained in another one:
>>{if $video.country|@count}
>>...output list of countries
>>{/if}
>
> {if count($video.country) != 0}
> ....
> {/if}
>
> should work just fine....
>
> Kind regards
>
> Thorsten
>
> --
> What's on a developers mind?
> http://blog.siteartwork.de