For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > March 2006 > RE: [SMARTY] Re: Variable into smarty array









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: [SMARTY] Re: Variable into smarty array
Alexandre Cognard

2006-03-20, 7:00 pm

Work fine, thanks !

Can we hope a better integration of array in future ?=20

Smarty is greatful :)

-----Message d'origine-----
De=A0: Pedro [mailto:daffodil@daffodil.uk.com]=20
Envoy=E9=A0: lundi 20 mars 2006 17:02
=C0=A0: smarty-general@lists.php.net
Objet=A0: [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=3Darray_key value=3D$offre[1].id_poste}
{$poste[$array_key]}

regards

Pete

Alexandre Cognard wrote:
> Hi everyone,
>=20
> I often need to use var inside array.
>=20
> Example:
> $poste =3D array("1"=3D>"poste1", "2"=3D>"poste2", "3"=3D>"poste3");
> $offre =3D array("1"=3D>array("nom"=3D>"myname","id_poste"=3D>"1")); =

(result from
a
> db query)
>=20
> I assign these array to smarty.
>=20
> Then into smarty:
> {$poste[1]} =3D> Poste1;
>=20
> {$offre[1].nom} =3D> myname
> {$offre[1].id_poste} =3D> 1
>=20
> But {$poste[$offre[1].id_poste]} result to an error.
> I try many syntax, but cant achieve my objective.
>=20
> 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).
>=20
> Regards,
> Alexandre Cognard


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

2006-03-20, 7:00 pm

--- Alexandre Cognard <alexandre@reseaulocal.fr> wrote:
> Work fine, thanks !
>
> Can we hope a better integration of array in future ?
>
> Smarty is greatful :)
>
> -----Message d'origine-----
> De�: Pedro [mailto:daffodil@daffodil.uk.com]
> Envoy�: lundi 20 mars 2006 17:02
> �: smarty-general@lists.php.net
> 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]}



This should also work:
{$poste[$offre.1.id_poste]}

-- boots

[color=darkred]
> regards
>
> Pete
>
> Alexandre Cognard wrote:
> a


________________________________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com