|
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 |
Brian Smarty Rookie
Joined: 29 Apr 2003 Posts: 21
|
Posted: Fri Sep 26, 2003 8:22 pm Post subject: Associative array keys with spaces in them? |
|
|
{$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 |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Sep 26, 2003 8:45 pm Post subject: |
|
|
Those are terrible key names. |
|
Back to top |
|
Brian Smarty Rookie
Joined: 29 Apr 2003 Posts: 21
|
Posted: Sat Sep 27, 2003 2:16 am Post subject: |
|
|
Granted. I did not pick them. But this is not the issue |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sat Sep 27, 2003 6:05 am Post subject: |
|
|
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 |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sun Sep 28, 2003 12:33 am Post subject: |
|
|
Brian wrote: | Granted. I did not pick them. But this is not the issue |
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 |
|
|
|
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
|