For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > April 2006 > Re: [SMARTY] finding array members









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] finding array members
boots

2006-04-06, 7:05 pm

Well, one simple way is to use php's array_keys as a modifier:

eg:

{assign var=keys value=$record|array_keys}

xo boots

--- D_C <lister@pikkle.com> wrote:

> i am working on a smarty template with some passed in arrays from
> another programmer.
>
> is there a way in smarty of walking through the array to find out the
> index names etc?
>
> eg in the .tpl
>
> {$array[0].key}
>
> or
>
> {foreach item=fitem key=fkey from=$titem}
> {$fkey}
>
> thanks!



________________________________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Mark Rogers

2006-04-06, 7:05 pm

boots wrote:
> Well, one simple way is to use php's array_keys as a modifier:
>
> eg:
>
> {assign var=keys value=$record|array_keys}


Presumably that should be:


{assign var=keys value=$record|@array_keys}

... to have array_keys act on the array as a whole, not on each array element individually.

--
Mark Rogers
More Solutions Ltd :: 0845 45 89 555
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com