Re: [SMARTY] Array keys, values
| From: | Christoph Boget | Date: | Mon, 15 Oct 2007 20:54:51 +0000 |
| Subject: | Re: [SMARTY] Array keys, values | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-13779@lists.php.net to get a copy of this message | ||
On 10/15/07, Max Schwanekamp <lists@neptunewebworks.com> wrote:
>
> Christoph Boget wrote:
> >If I have an array that looks like this:
> >Array ([Salary] => Array ( [0-50K] => Array ( [filterType] => range ) ) )
> >
> >How can I access the key values? Individually, that is. What about the
> >child array key/values? Individually, that is.
>
> {$myArray.Salary.0-50K.filterType} should work, but the key 0-50K might be
> problematic due to the leading numeric character (I haven't tried it). If
> it doesn't work, try adding a leading alpha char to those key names.
And if I don't know the key value off hand because the array was generated
dynamically?
As an aside, 2 features that would be really nice when working with arrays
in a smarty template:
* get the total count of the elements w/o having to iterate through the
array
* be able to access the first or last element even if the keys aren't
numeric
thnx,
Christoph