|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Enquest Smarty Regular
Joined: 14 May 2003 Posts: 79
|
Posted: Wed Oct 08, 2003 4:51 pm Post subject: print key |
|
|
How to print the key('s) of an array?
How to do this with out flipping the array!
array_flip _________________ -----------------------
Learning my self by trying to help others |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Oct 08, 2003 7:13 pm Post subject: |
|
|
Code: | {foreach from=$arr key=k item=v}
{$k} = {$v}<br/>
{/foreach} |
|
|
Back to top |
|
Enquest Smarty Regular
Joined: 14 May 2003 Posts: 79
|
Posted: Wed Oct 08, 2003 7:29 pm Post subject: |
|
|
And how would you do this in
{html_options name=place values=$buildings selected=$where.0.place output=$buildings} _________________ -----------------------
Learning my self by trying to help others |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Oct 08, 2003 7:48 pm Post subject: |
|
|
Enquest wrote: | And how would you do this in
{html_options name=place values=$buildings selected=$where.0.place output=$buildings} |
i'm not sure what you want, but i would do maybe:
{html_options name=place options=$buildings selected=$where.0.place} |
|
Back to top |
|
Enquest Smarty Regular
Joined: 14 May 2003 Posts: 79
|
Posted: Wed Oct 08, 2003 7:57 pm Post subject: |
|
|
what I want is the selected part points prints the key and not the =>string.
Its because my select box needs to be selected on the key.
If I could writn {where.0.place|key} to print a key that would be great!
Thanxs for the help. _________________ -----------------------
Learning my self by trying to help others |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Oct 08, 2003 9:43 pm Post subject: |
|
|
... selected=$where.0.place|@array_keys ...
you can use php-functions as modifiers.
you have to use the @-operator to pass the value literally to the modifier, the modifier would be called for each value of $where.0.place otherwise (obviously not intended here).
see http://smarty.php.net/manual/en/language.modifiers.php |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|