473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

multidimensional arrays passed to Smarty?

Does Smarty support assigning multidimensional arrays? I've tried to get
it working, but just can't get it.

can someone help me?
this is what I have in my php file:

$side_bar =
array('link' => array( 'index.php',
'estate.php',
'text' => array( 'Home',
'Real Estate')));
$smarty->assign ("side_bar", $side_bar);

then in my template file I have this:

{section name=i loop=$side_bar}
<tr><td width="19"><img src="images/td_background_left.gif" width="19"
height="22" alt="" border="0"></td>
<td align="left" valign="center" height="22" width="118"
background="images/td_background_right.gif">
<p><span style="font-family: Arial; color:black; font-size: 8pt;">
{if $side_bar.link.i neq ""}
<a href= {$side_bar.link.i} style="text-decoration:none; color:black;">
<b>& {$side_bar.text.i}</b></a></span></p></td></tr>
{else}
<a><b>&{$side_bar.text.i}</b></a></span></p></td></tr>
{/if}
{/section}

with this code, only one row is produced in the table. I guess it's
because $side_bar only has two values which have more values beneath
them. How can I create a side bar that will have the link and then text
that I store in the array? Does it work to have an Associative array
mixed with an Indexed array, and then display the indexed array the way
I tried?

Obviously it does not work like this. I'm fairly new to PHP and Smarty,
so if anyone has suggestions on how I can get this done, please tell me.

Thanks,
Mark
Jul 17 '05 #1
2 14009
In article <44******************************@news.teranews.co m>,
Mark <do***************@hotmail.com> wrote:
Does Smarty support assigning multidimensional arrays? I've tried to get
it working, but just can't get it.


Yes. I use them in {foreach} loops, like this:

{foreach from=$multi_dimensional_array item=array}
<tr><td>{$array.value1}</td><td>{$array.value2}</td></tr>
{/foreach}

JP

--
Sorry, <de*****@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Jul 17 '05 #2
Jan Pieter Kunst wrote:
In article <44******************************@news.teranews.co m>,
Mark <do***************@hotmail.com> wrote:

Does Smarty support assigning multidimensional arrays? I've tried to get
it working, but just can't get it.

Yes. I use them in {foreach} loops, like this:

{foreach from=$multi_dimensional_array item=array}
<tr><td>{$array.value1}</td><td>{$array.value2}</td></tr>
{/foreach}

JP


Thank you, I got it to work now.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Golf Nut | last post by:
I am finding that altering and affecting values in elements in multidimensional arrays is a huge pain in the ass. I cannot seem to find a consistent way to assign values to arrays. Foreach would...
2
by: shane | last post by:
Ive searched a fair bit for the answer, but nothing has come up that matches what i want to do. I'm having an issue with passing and assigning pointers to multidimensional arrays. The code: ...
2
by: Terry | last post by:
Hi, can someone plz tell me how multidimensional arrays (like a 2-D array) are stored in memory? Are they like single dimensional arrays? Stored sequentially in one "row", so to say? Thanks ...
9
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the...
3
by: Claire | last post by:
I have a multidimensional array defined as private double myArray = new double; The first column of the array contains X values, the other contains Y values I have a charting function defined as...
3
by: Ravi Singh (UCSD) | last post by:
Hello all I am trying to use jagged and multi-dimensional arrays in C++. In C# these work fine // for jagged arrays string jaggedArray = new string ; //for multidimensional arrays string...
21
by: utab | last post by:
Hi there, Is there a way to convert a double value to a string. I know that there is fcvt() but I think this function is not a part of the standard library. I want sth from the standard if...
10
by: | last post by:
I'm fairly new to ASP and must admit its proving a lot more unnecessarily complicated than the other languages I know. I feel this is because there aren't many good official resources out there to...
9
by: Slain | last post by:
I need to convert a an array to a multidimensional one. Since I need to wrok with existing code, I need to modify a declaration which looks like this In the .h file int *x; in a initialize...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.