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

Associative array keys with spaces in them?

 
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
Brian
Smarty Rookie


Joined: 29 Apr 2003
Posts: 21

PostPosted: Fri Sep 26, 2003 8:22 pm    Post subject: Associative array keys with spaces in them? Reply with quote

{$array.Last Name} gives an error. The array keys have spaces in them. Is there a way to access these within smarty? The array looks something like:

Code:

$user = array(
    'Last Name' => 'Jones',
    'First Name' => 'Frank'
);


Thanks in advance,
Brian
Back to top
View user's profile Send private message Send e-mail
boots
Administrator


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

PostPosted: Fri Sep 26, 2003 8:45 pm    Post subject: Reply with quote

Those are terrible key names.
Back to top
View user's profile Send private message
Brian
Smarty Rookie


Joined: 29 Apr 2003
Posts: 21

PostPosted: Sat Sep 27, 2003 2:16 am    Post subject: Reply with quote

Granted. I did not pick them. But this is not the issue Sad
Back to top
View user's profile Send private message Send e-mail
messju
Administrator


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

PostPosted: Sat Sep 27, 2003 6:05 am    Post subject: Reply with quote

i think it's only possible with an intermedia var:
{assign var=key value="Last Name"}{$array.$key}

or you have to write a modifier one-liner that performs
{$array|key:"Last Name"}
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


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

PostPosted: Sun Sep 28, 2003 12:33 am    Post subject: Reply with quote

Brian wrote:
Granted. I did not pick them. But this is not the issue Sad

I was not very diplomatic there. My apologies!

Personally, I would try to get it fixed in the right location (and perhaps shoot the person selecting those names). So instead of munging the Smarty code or creating a mapping function in PHP (for example, one that replaced blanks with underscores) I would try to get the definitions fixed.

Oh yeah, and shoot the person selecting those names.
Back to top
View user's profile Send private message
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