Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-03-2007, 12:17 PM   PM User | #1
daemonkin
Regular Coder

 
Join Date: Jun 2007
Location: N. Ireland
Posts: 351
Thanks: 16
Thanked 4 Times in 4 Posts
daemonkin is on a distinguished road
Smarty Concatenation

Hi,

I have a number of arrays assigned in PHP, all beginning with 'aKit_' followed by the type of kit. All kit types are assigned also as aKitTypes so I have all my kit types and kit type names assigned to the template.

I don't want to write out the same code for 14 different kit types and want to run a foreach through the kit types array and get the name out and then run through the array 'aKit_X' where X is the name of the array assigned and passed into the template.

I have tried 'cat' as in:
PHP Code:
{foreach from=$aKitTypes key=key item=type}
<
h3>{$type|capitalize}</h3>
{foreach 
from=$'aKit_'|cat:$key key=key2 item=kit}
{
$key2}
{/foreach}
{/foreach} 
but this is not working.

I would appreciate any help with this.

Edit:
This works but needs to be done for each type:
PHP Code:
<h4>Kit Socks</h4><table class="kit_breakdown"><tr><th>Colour/Size: </th>{foreach from=$aSizes key=size_key item=size}<th class="size">{$size}</th>{/foreach}</tr>
     {foreach 
from=$aKit_kit_socks key=key item=item}
          <
tr>
         <
td>{$item.description}</td>
{foreach 
from=$aSizes key=size_key item=size}
          <
td>{$item.$size}</td>
{/foreach}
     </
tr>
     {/foreach}
     </
table
D.
__________________
Daemonkin.
If this was helpful, please add to my reputation
Thousand Sons - Freelance Web Developer - ninetyonedegrees.com
daemonkin is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:22 AM.


Advertisement
Log in to turn off these ads.