Categories > TinyButStrong general >

Help with nested Array (again)

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Andreas
Date: 2005-03-23
Time: 22:32

Help with nested Array (again)

Hi,

I try to use TBS in my current Project. I have to try to generate some JS Code with it.

First my PHP Code:
$item[] = array('id'=>'a1','items' => array('t1','t2','t3','t4'));
  $item[] = array('id'=>'a2','items' => array('t11','t22','t33','t44'));
  $item[] = array('id'=>'a3','items' => array('t111','t222','t333','t444'));
  $item[] = array('id'=>'a4','items' => array('t1111','t2222','t3333','t4444'));
  $item[] = array('id'=>'a5','items' => array('t11111','t22222','t33333','t44444'));

  $TBS->MergeBlock('item','array','item') ;
  $TBS->MergeBlock('subitem',$item['items']) ;

And I want to generat Code like this

<script type="text/javascript">
    var SELECT_update2ndData = new Array();
    SELECT_update2ndData['a1'] = new Array('test1','test2','test3','test4');
    SELECT_update2ndData['a2'] = new Array('test11','test22','test33','test44');
    SELECT_update2ndData['a3'] = new Array('test111','test222','test333','test444');
    SELECT_update2ndData['a4'] = new Array('test1111','test2222','test3333','test4444');
</script>

I hope someone can help me. I have read most of the Posts in the Forum, but I failed on my code... :(


thanks in advance
Andreas
By: Skrol29
Date: 2005-03-24
Time: 01:18

Re: Help with nested Array (again)

Hello,

I suggest that you use parameter 'onsection' to call a user function that will convert the 'items' array into a string. Using the implode() Php function for example.
By: Andreas
Date: 2005-03-29
Time: 10:10

Re: Help with nested Array (again)

Ok, thank you very much -  I will try it as soon as possible :)