Re: [SMARTY] {section} docs, was: Re: [SMARTY] Newbie Question: Associative Arrays and Sections
| From: | Matt Warden | Date: | Mon, 04 Jul 2005 16:50:12 +0000 |
| Subject: | Re: [SMARTY] {section} docs, was: Re: [SMARTY] Newbie Question: Associative Arrays and Sections | ||
| References: | 1 2 3 4 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-12772@lists.php.net to get a copy of this message | ||
Mark,
On 7/4/05, Mark Rogers <mark@quarella.co.uk> wrote:
> In most cases, and in ALL cases involving associative
> (non-numeric indexed) arrays or numerical indexes
> which don't increment from zero, you should use
> {foreach} rather than {section}.
>
I have looked at the docs for section and foreach many times, and
while I had a general intuition for how to use each, *when* to use
each hadn't become clear until I read this (and the previous mention
from maju(I think) about only using arrays indexed from 0...n-1).
Definitely a +1 for the note added to the docs.
In fact, I was primarily mislead by this note in the docs:
"The syntax for {foreach} is much easier than {section}, but as a
tradeoff it can only be used for a single array."
which, to me, implies that they serve the same purpose and can be used
on the same array types, with the caveat being noted.
--
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com
This email proudly and graciously contributes to entropy.