Re: [SMARTY] Testing if an array is empty?

From: Date: Wed, 11 Dec 2002 00:33:26 +0000
Subject: Re: [SMARTY] Testing if an array is empty?
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6725@lists.php.net to get a copy of this message
Whats about {sectionelse}? > I have a table row with two columns. The left column has a static html > header "Authors" and the right one contains a smarty section loop to > output author names fetched from a database as a smarty array variable. > > How can I test if there are any elements in the authors array (or any > smarty array variable)? {if $authors != ''}{/if} or similar structures > don't work. I need kind of a {if $array is empty}structure > > I mean not to print this html row at all if section loop will print > nothing. I cant use smarty.section.name.total as I have to test it > before the loop to get rid off the static header. > > > {if $sisbn not empty} // this is what I would need, but is illegal > <tr> > <td bgcolor="#FFFFEE">Authors</td> > <td bgcolor="#FFFFEE"> > {section name=id loop=$sisbn} > {$authors[id]}{if not $smarty.section.id.last} ;{/if} > {/section} > </td> > </tr> > {/if} > > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.general (#6725) next »