RE: [SMARTY] {section} with array that doesnt start with index 0
| From: | Peter Billen | Date: | Mon, 19 Aug 2002 10:19:17 +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-5754@lists.php.net to get a copy of this message | ||
Ok yes, I understand it's indeed a better for the future (skins etc...)
to have "standard" arrays (starting with index 0 it is)
But what is then the best option to construct the array:
$array[0]['countryName'] = "Belgium";
$array[0]['countryNameShort'] = "BE";
$array[1]['countryName'] = "United Kingdom";
$array[1]['countryNameShort'] = "UK";
or
$array['countryNames'][0] = "Belgium";
$array['countryNamesShort'][0] = "BE";
$array['countryNames'][1] = "United Kingdom";
$array['countryNamesShort'][1] = "UK";
I myself suppose the best one is the first one, because it's easier (is
it?) to loop through. However with option 1, I guess you can't use the
array_push function.
Thanks for your suggestions,
Peter
-----Original Message-----
From: Roman Neuhauser [mailto:neuhauser@bellavista.cz]
Sent: maandag 19 augustus 2002 9:43
To: 'Smarty General'
Subject: Re: [SMARTY] {section} with array that doesnt start with index
0
> From: "Peter Billen" <peter@clueless.be>
> To: "'Smarty General'" <smarty-general@lists.php.net>
> Date: Sun, 18 Aug 2002 22:45:35 +0200
> Subject: RE: [SMARTY] {section} with array that doesnt start with
index 0
> 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?
absolutely no. it's just-so as long as you can keep you hands on
both the code and the templates, but as soon as these two are truly
separated, you either must document the {section} breakage with
associative (or non-zero-based) arrays for the template authors, or
use array_values() everywhere.
--
FreeBSD 4.6-STABLE
9:40AM up 9 days, 21:35, 19 users, load averages: 0.00, 0.00, 0.00
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php