|
Posted by Matt Warden on 09/28/12 11:20
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.
Navigation:
[Reply to this message]
|