|
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 |
Nilda Smarty n00b
Joined: 16 Apr 2015 Posts: 1
|
Posted: Thu Apr 16, 2015 5:26 pm Post subject: how t o use a loop in an multidimentional array |
|
|
$orders =Array ( [110] => Array ( [name] => Array ( [0] => Canadian Children's Book News Winter 2015 [1] => Canadian Children's Book News Subscription +Best Books for Kids & Teens [2] => Best Books for Kids & Teens: Annual, 2008 ) [product_id] => Array ( [0] => 22 [1] => 14 [2] => 26 ) ) [111] => Array ( [name] => Array ( [0] => Canadian Children's Book News Winter 2015 [1] => Canadian Children's Book News Subscription +Best Books for Kids & Teens [2] => Bookmarks - Hear Our Stories ) [product_id] => Array ( [0] => 22 [1] => 14 [2] => 41 ) ) [112] => Array ( [name] => Array ( [0] => Canadian Children's Book News Winter 2015 [1] => Canadian Children's Book News Subscription +Best Books for Kids & Teens ) [product_id] => Array ( [0] => 22 [1] => 14 ) ) )
$this->assign('orders', $orders);
I used:
{foreach from=$orders item=ord}
{foreach from=$ord item=type}
{foreach from=$type item=cat}
<p>product: {$cat.name}<br />
{/foreach}
{/foreach}
{/foreach}
but doesn't display the name
Thank you |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Apr 16, 2015 9:35 pm Post subject: |
|
|
This should do it
Code: | {foreach from=$orders item=ord}
{foreach from=$ord.name item=name}
<p>product: {$name}<br />
{/foreach}
{/foreach}
|
|
|
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
|