Re: [SMARTY] Foreach - get the line number
| From: | messju mohr | Date: | Wed, 02 Jul 2003 14:59:46 +0000 |
| Subject: | Re: [SMARTY] Foreach - get the line number | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9810@lists.php.net to get a copy of this message | ||
On Wed, Jul 02, 2003 at 04:39:12PM +0200, Olivier Doucet [reagi.com] wrote:
> I'm using foreach to go throuh a big array.
> But i want to show the number of the line.
>
> {foreach from=$lesfiches item=fiche}
> $i - <a href="ct_faq.php?id={$fiche.id}">{$fiche.titre}</a><br>
>
> {/foreach}
{foreach from=$lesfiches key=i item=fiche}
{$i} - ...
{/foreach}
or
{foreach name=f from=$lesfiches item=fiche}
{$smarty.foreach.f.iteration} - ...
{/foreach}
the former is documented at:
http://smarty.php.net/manual/en/language.function.foreach.php
the latter is only in the cvs-version of the docs, but available in
smarty since 2.3.x AFAIK.
> Replace $i by the number of the line, ie :
> 1- <a href="ct_faq.php?id=51">Title</a><br>
> 2- <a href="ct_faq.php?id=31">Title</a><br>
> 3- <a href="ct_faq.php?id=47">Title</a><br>
>
> I haven't seen how to do this in the doc. Can u help me ?
>
> Thx a lot :)
>
>
> Olivier Doucet
> www.ajeux.com
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php