Re: [SMARTY] Array keys, values

"Christoph Boget" <[email protected]> Mon, 15 Oct 2007 16:54:51 -0400
Newsgroups gmane.comp.php.smarty.general
Message-ID <[email protected]>
------=_Part_14527_21439868.1192481691889
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 10/15/07, Max Schwanekamp <[email protected]> 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

------=_Part_14527_21439868.1192481691889--