RE: [SMARTY] {section} with array that doesnt start with index 0
| From: | Peter Billen | Date: | Sun, 18 Aug 2002 20:45:35 +0000 |
| Subject: | RE: [SMARTY] {section} with array that doesnt start with index 0 | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5742@lists.php.net to get a copy of this message | ||
doh! :)
That was very simple :) thanks a lot Mark!
However, this problem made me wondering about how to construct an array
to use with Smarty. Is it a good idea to take primary keys as indices?
I mean, what would be the best option to take:
1)
$array[$row['key']]['tag'] = "text";
2)
$array[0]['tag'] = "text";
$array[0]['key'] = $row['key'];
I have always chosen the first one, because if I use multiple queries
that puts information in the same array (in this case $array), I needed
the previous keys. For example:
$array[$country_key]['cities'][$city_key]['regions'][$region_key]['habit
ants'][$habitant_id]['habitant_name'] = "Peter";
+ It keeps the logical structure of the database.
What do you guys think of this, or how do you handle with this?
Peter
-----Original Message-----
From: Mark Rogers [mailto:mark@quarella.co.uk]
Sent: zondag 18 augustus 2002 22:35
To: peter@clueless.be; 'Smarty General'
Subject: Re: [SMARTY] {section} with array that doesnt start with index
0
> But with the {foreach} loop, I had some layout errors: after every
loop
> I print a "<br>" (or something else). But I don't want that when the
> foreach ends (so at the last loop). Since foreach doesn't support "{if
> $smarty.section.games.last <> true}", I had to convert my foreach into
a
> section.
You will find that $smarty.foreach.games.last will do what you need here
(in
place of $smarty.section...} - although it doesn't seem to be
documented.
Mark Rogers
Quarella Ltd