Re: Associative arrays question

From: Date: Thu, 03 Jan 2002 14:28:35 +0000
Subject: Re: Associative arrays question
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2488@lists.php.net to get a copy of this message
On Thu, 03 Jan 2002, Alain Fontaine - Consultant and developer wrote: > 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 &agrave; > manger", > "Jardin" => "Jardin", > "Garage" => "Garage", > "Parking" => "Parking", > "Ascenseur" => "Ascenseur", > "Cave" => "Cave", > "Renove" => > "R&eacute;nov&eacute;", > "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... Use the new {foreach} construct. It's documented. -Andrei Programming X-Windows is like trying to find the square root of pi using roman numerals. - Henry Spencer

« previous php.smarty.general (#2488) next »