Re: count element of array ?

From: Date: Thu, 08 Apr 2004 03:24:31 +0000
Subject: Re: count element of array ?
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11248@lists.php.net to get a copy of this message
for the first questoin {foreach name=test from=$custid item=curr_id} {$curr_id} {if $smarty.foreach.test.last != $smarty.foreach.test.total},{/if} {/foreach} second {foreach name=test from=$custid item=curr_id} {$smarty.foreach.test.iteration}{$curr_id}<br> {/foreach} Best Regards, Protect "Adwinwijaya" <adwinwijaya@yahoo.com.au> ??? news:1232488332.20040408104858@yahoo.com.au ???... > Hello smarty-general, > > Is there any function to count the number of element in an array > that passed to smarty ? > > I need that to formating the string ... > for example I have an array contain {'a','b','c','d'} > and I want to print it as a,b,c,d (with ',') but after d .. it > doesnt need to add ',' .. > > and for foreach(), how to get the current index ? > forexample: > {foreach from=$custid item=curr_id} > id: {$curr_id}<br> > {/foreach} > > I want to display it as: > 1. curr_id > 2. curr_id > 3. curr_id ...etc etc ? > > > -- > Best regards, > adwin

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