Categories > TinyButStrong general >

array list ignores repeated key

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: kle_py
Date: 2010-08-02
Time: 19:22

array list ignores repeated key

I am using TBS for some internal projects at work and i find it really usefull :) .
However now i have an effect, where it does not work as expected.

When i modify the 2nd. example of the manual to:
$list = array('X','Y','X','Y','Z') ;
$TBS->MergeBlock('blk',$list) ;
the result is as expected: i can see 5 items, the items 'X' and 'Y' appear several times.

Based on this i wanted to create a simple menu like:
$list = array('Xurl' => 'X1','' => '<hr>','Yurl' => 'Y3','Y4url' => 'Y4','' => '<hr>','Zurl' => 'Z5') ;
$TBS->MergeBlock('menu',$list) ;
for a template like:
<ul>
<li><a href="?sub=[menu.$;block=li;magnet=a;mtype=m+m;]">[menu.val;htmlconv=no]</a></li>
</ul>
My idea is to use an empty key value to create some visual dividing lines - using the html code.
This does work - as long as i have only ONE empty element.
However, when inserting several empty seperator keys - it seems the "first" empty key is overwritten (in place), and i don't get a "new" dividing line !
Seems repeated key values are not allowed :( .

I don't know if it is a bug, or a feature - or did i miss some parameter ?
If there is a parameter or a simple workaround, i would appreciate a pointer.

Thanks
By: kle_py
Date: 2010-08-02
Time: 19:32

Re: array list ignores repeated key

well, ok, i see.
It simply a PHP feature.
Double keys are "overwritten" by their latest value. i just verified with print_r.
:/

Means - TBS has not its "hands" in it.
Will look for a better workaround now..