RE: [SMARTY] Re: Variable into smarty array

"Alexandre Cognard" <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Message-ID <[email protected]>
Work fine, thanks !

Can we hope a better integration of array in future ? 

Smarty is greatful :)

-----Message d'origine-----
De : Pedro [mailto:[email protected]] 
Envoyé : lundi 20 mars 2006 17:02
À : [email protected]
Objet : [SMARTY] Re: Variable into smarty array

instead of {$poste[$offre[1].id_poste]}

which the smarty parser dont like

try assigning the array_key to a variable first
{assign var=array_key value=$offre[1].id_poste}
{$poste[$array_key]}

regards

Pete

Alexandre Cognard wrote:
> Hi everyone,
> 
> I often need to use var inside array.
> 
> Example:
> $poste = array("1"=>"poste1", "2"=>"poste2", "3"=>"poste3");
> $offre = array("1"=>array("nom"=>"myname","id_poste"=>"1")); (result from
a
> db query)
> 
> I assign these array to smarty.
> 
> Then into smarty:
> {$poste[1]} => Poste1;
> 
> {$offre[1].nom} => myname
> {$offre[1].id_poste} => 1
> 
> But {$poste[$offre[1].id_poste]} result to an error.
> I try many syntax, but cant achieve my objective.
> 
> Is there's a way ? Or I need to do it into php (I do it most of time, but
> not very appropriate in whole case).
> 
> Regards,
> Alexandre Cognard

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.