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

dashed array 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
sushko
Smarty Rookie


Joined: 14 Feb 2019
Posts: 5

PostPosted: Thu Feb 14, 2019 1:03 pm    Post subject: dashed array key Reply with quote

I have an array:

$activity = array("name" => "Challenge", "start-date" => "2019/02/14");

In order to output this variable, in the TPL file I put:

{$activity.start-date}

Unfortunately it does not work since Smarty engine interprets the hyphen as a minus sign.

Is there a way to output this array element anyhow without renaming it or copying the value to a different variable?
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Thu Feb 14, 2019 7:01 pm    Post subject: Reply with quote

I believe this works:
Code:
{$activity['start-date']}
Back to top
View user's profile Send private message
sushko
Smarty Rookie


Joined: 14 Feb 2019
Posts: 5

PostPosted: Thu Feb 14, 2019 7:35 pm    Post subject: Reply with quote

That worked, thank you!
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