Categories > TinyButStrong general >

array of array

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Val
Date: 2004-07-29
Time: 16:31

array of array

I have an array ($table) of arrays, and I try to display each array in the array($table) in columns. But I can't...

Exemple:

$table = Array ( [device] => Array ( [1] => HSS01 [2] => LSF01 [3] => ALS01 [4] => ALS01 ) [refnam] => Array ( [1] => AUT01 [2] => SF001 [3] => IUAL1 [4] => IUAL1  ) )

$dataTBS->MergeBlock('blk1',$table) ;

HTML code:
    [blk1;block=begin]
    <tr>
        <td>[blk1.device.val]</td>
        <td class="special">[blk1.refnam.val]</td>
    </TR>
    [blk1;block=end]

The error message says that there is no key named "device" and no key named "refnam"!

The result that I would like to have is

<tr><td>HSS01</td><td class="special">AUT01</td></tr>
<tr><td>LSF01</td><td class="special">SF001</td></tr>
<tr><td>ALS01</td><td class="special">IUAL1</td></tr>
<tr><td>ALS01</td><td class="special">IUAL1</td></tr>

Can someone help me? What are the tags that I should use in the html code?
By: Skrol29
Date: 2004-07-29
Time: 18:11

Re: array of array

Hmmmmm,

TBS merges you array this way:
  first record = array(1=>HSS01,2=>LSF01,3=ALS01,4=>ALS01)
  second record = array(1=>AUT01,2=>SF001,3=>IUAL1,4=>IUAL1)
Key names of records cant' be read when records are arrays.

If you can, it would be better to structure your array another way.
Like:
$table = array(
  array('device'=>'HSS01','refnam'=>'AUTO1')
,array('device'=>'LSF01','refnam'=>'SF001')
,...
);

Or you can do the following:
PHP:
$device = $table['device'];
$refnam = $table['device'];
$dataTBS->MergeBlock('blk1',$device) ;
HTML:
[blk1;block=begin]
<tr>
<td>[blk1.val]</td>
<td class="special">[var.refnam.[blk1.key]]</td>
</TR>
[blk1;block=end]


By: Val
Date: 2004-07-30
Time: 09:49

Re: array of array

Thank you for your answer.  Your second idea seems to be the best way to do it.