Re:Associative arrays question
| From: | Brian E . Lozier | Date: | Thu, 03 Jan 2002 11:06:45 +0000 |
| Subject: | Re:Associative arrays question | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-2485@lists.php.net to get a copy of this message | ||
You should use the new {foreach} instead of {section}
Brian
----- Original Message -----
From: "Alain Fontaine - Consultant and developer" <alain@valain.com>
To: smarty@lists.ispi.net
Date: 1/3/02 2:30:25 AM
>
>Hello everyone, and a happy new year 2002! ;)
>
> I have a question with regard to associative arrays. Given the associative
>array below:
>
> $arrCriteresRecherche = array( "SalleAManger" => "Salle à
>manger",
> "Jardin" => "Jardin",
> "Garage" => "Garage",
> "Parking" => "Parking",
> "Ascenseur" => "Ascenseur",
> "Cave" => "Cave",
> "Renove" =>
> "Rénové",
> "GrenierMansarde" =>
> "Grenier/Mansarde",
> "AppartGardien" => "Appartement
> gardien",
> "ChambreFroide" => "Chambre froide" );
>
> I wonder how I can build a {section} that would somehow work like this:
>
>{section name=criteres loop=$arrCriteresRecherche}
><input type="checkbox" name="{$arrCriteresRecherche[criteres].KEY}"
>value="{$arrCriteresRecherche[criteres].VALUE}">
>{/section}
>
> And all this WITHOUT having to use two different arrays, one for the names
>and one for the values. The problem with this assoc. array is that I don't
>know the array's keys by name because they might be built dynamically...
>
> Thanks! ;)
>
>-----------------------
>Alain Fontaine
>Consultant & Developer
>VAlain S.A.
>Tél: +32-4-2522950
>-----------------------
>
>
>---
>You are currently subscribed to smarty as: brian@massassi.net
>To unsubscribe send a blank email to $subst('Email.Unsub')
>Visit Smarty's homepage at
>http://www.phpinsider.com/php/code/Smarty/