Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Creating an array in Smarty
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
czarnowski
Guest





PostPosted: Thu Jan 17, 2008 11:45 am    Post subject: Reply with quote

To assign an array with this values

"one", "two", "three"

you can do this:


{assign var='myarray' value=','|explode:"one,two,three"}
Back to top
cjxxi
Smarty Regular


Joined: 03 Aug 2007
Posts: 40
Location: Fort Worth,Texas

PostPosted: Sun Sep 14, 2008 9:07 am    Post subject: Reply with quote

Check out this plugin, which allows you to create an associate or non-associate array with smarty Very Happy


http://www.phpinsider.com/smarty-forum/viewtopic.php?t=14132


... In response to the original post, this would go something like this... (if using the plugin)
Code:

   {array vars='array("one", "two", "three")'  assign='arg'}
   
   {include file="Foo.tpl" arg=$arg}

_________________
CJAX THE PHP AJAX FRAMEWORK AT CJAX.NET
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4668
Location: Hamburg / Germany

PostPosted: Tue Mar 20, 2012 3:10 pm    Post subject: Reply with quote

You can define arrays within templates.
Examples:
{assign var=foo value=[1,2,3]}
{assign var=foo value=['y'=>'yellow','b'=>'blue']}
Arrays can be nested.
{assign var=foo value=[1,[9,8],3]}

So PHP array(....) is just [....] in Smarty templates.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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