Categories > TinyButStrong general >

show item of array by key

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: mohammed
Date: 2012-08-15
Time: 16:23

show item of array by key

i have an array

$numeros=array('1'=>'France','54'=>'Fes');
$oPage->MergeBlock('numeros',$numeros);

and i whant to show value from this array by key

itray this [numeros[54];noerr]  to show 'Fes'

plz help me
By: Skrol29
Date: 2012-08-15
Time: 20:17

Re: show item of array by key

Hi Mohammed,

MergeBlock() displays a set of values.
For displaying only one item, use MergeField().

PHP :
$oPage->MergeField('numeros',$numeros);
HTML :
[numeros.54]
By: Mohammed
Date: 2012-08-17
Time: 16:35

Re: show item of array by key

THX it work , but i have a probelem, if the index is an item of an other array

i tray to do this : [numeros.[user.id]] but  no result
By: Skrol29
Date: 2012-08-17
Time: 17:13

Re: show item of array by key

And what [user.id] is supposed to display ?
By: Mohammed
Date: 2012-08-17
Time: 17:15

Re: show item of array by key

yes i work i can desplay [user.id] but when i whant to use it as index for numeros array i don't have anay result
By: Skrol29
Date: 2012-08-18
Time: 02:24

Re: show item of array by key

You have to give more details. It's not the same thing if [user.id] is a single value or if it's a field in a block that will be repeated.