PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.smarty.general > problem with dynamic "array key" in smarty
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
problem with dynamic "array key" in smarty

Réponse
 
LinkBack Outils de la discussion
Vieux 23/10/2006, 10h02   #1 (permalink)
rs_satya
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut problem with dynamic "array key" in smarty


I need to send an array value as a key to another array dynamically in a
template.
pls . me.

the sample code is as follows:

{foreach name=outer item=hno key=key from=$hoas}
<tr>
<td>
{$hno.sno} //OK

{$be[{$hno.sno}]} //I tried like this -- Wrong

// Here I need to send this {$hno.sno} value as a key to {$be[]} associative
array.

</td>
</tr>
{/foreach}
--
View this message in context: http://www.nabble.com/problem-with-d....html#a6950437
Sent from the Smarty - General mailing list archive at Nabble.com.
  Réponse avec citation
Vieux 25/10/2006, 09h31   #2 (permalink)
Peggy Schatz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: problem with dynamic "array key" in smarty

Hi,

try

{$be.$hno.sno}

even though I can't figure out where .sno comes from...


The following works and puts out the desired values of $be:

{foreach name=outer item=hno key=key from=$hoas}
<tr>
<td>
{$be.$hno}
</td>
</tr>
{/foreach}

and:

$be=array('bli'=>1,'bla'=>2,'blu'=>3,'blo'=>4);
$hoas=array('test1'=>'bli','test2'=>'bla','test3'= >'blo','test4'=>'blu');
$smarty->assign('hoas',$hoas);
$smarty->assign('be',$be);

rs_satya schrieb:
> I need to send an array value as a key to another array dynamically in a
> template.
> pls . me.
>
> the sample code is as follows:
>
> {foreach name=outer item=hno key=key from=$hoas}
> <tr>
> <td>
> {$hno.sno} //OK
>
> {$be[{$hno.sno}]} //I tried like this -- Wrong
>
> // Here I need to send this {$hno.sno} value as a key to {$be[]} associative
> array.
>
> </td>
> </tr>
> {/foreach}

  Réponse avec citation
Vieux 25/10/2006, 17h46   #3 (permalink)
Ken Snyder
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] problem with dynamic "array key" in smarty

Are you looking for

{$be[$hno.sno]}

?

rs_satya wrote:
> I need to send an array value as a key to another array dynamically in a
> template.
> pls . me.
>
> the sample code is as follows:
>
> {foreach name=outer item=hno key=key from=$hoas}
> <tr>
> <td>
> {$hno.sno} //OK
>
> {$be[{$hno.sno}]} //I tried like this -- Wrong
>
> // Here I need to send this {$hno.sno} value as a key to {$be[]} associative
> array.
>
> </td>
> </tr>
> {/foreach}
>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h41.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07676 seconds with 11 queries