Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

print key

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Enquest
Smarty Regular


Joined: 14 May 2003
Posts: 79

PostPosted: Wed Oct 08, 2003 4:51 pm    Post subject: print key Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Oct 08, 2003 7:13 pm    Post subject: Reply with quote

Code:
{foreach from=$arr key=k item=v}
  {$k} = {$v}<br/>
{/foreach}
Back to top
View user's profile Send private message
Enquest
Smarty Regular


Joined: 14 May 2003
Posts: 79

PostPosted: Wed Oct 08, 2003 7:29 pm    Post subject: Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Oct 08, 2003 7:48 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Enquest
Smarty Regular


Joined: 14 May 2003
Posts: 79

PostPosted: Wed Oct 08, 2003 7:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Oct 08, 2003 9:43 pm    Post subject: Reply with quote

... 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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP