Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

dashed array key

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
sushko
Smarty n00b


Joined: 14 Feb 2019
Posts: 2

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 Pro


Joined: 20 Dec 2011
Posts: 245
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 n00b


Joined: 14 Feb 2019
Posts: 2

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:   
Post new topic   Reply to topic    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