Re: [SMARTY] Concatenated string as array index

From: Date: Wed, 26 May 2004 15:38:51 +0000
Subject: Re: [SMARTY] Concatenated string as array index
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11413@lists.php.net to get a copy of this message
Hello, I don't think that's possible. I'd rather recommend to change the array slightly: $entry = array( "de" => array( "text" => "Deutscher text", "head" => "Deutsche Ueberschrift", ) "en" => array( "text" => "english text", "head" => "english headline", ) ); That'd be easier to handle. - david On Wed, 26 May 2004 17:21:48 +0200 Gabriel Birke <birke@kontor4.de> wrote: > Hello! > > I've got the following array: > $entry = array( > "text_de" => "Deutscher text", > "text_en" => "english text" > "head_de" => "Deutsche Ueberschrift", > "head_en" => "english headline" > ); > > The variable $l stores the locale abbreviation ("en" or "de") > > Something like > echo $entry["head_".$l]."<br>".$entry["text_".$l]; > is very elegant. Is a statement like this possible in Smarty? > > Or do i have to assign the correct field names from php like this: > > $smarty->assign("text_local", "text_".$l); > $smarty->assign("head_local", "head_".$l); > > In the template: > {$entry.$head_local}<br />{$entry.$text.local} > > With best regards > > Gabriel Birke > > -- > KONTOR4_Neue Medien > Plathnerstraße 5 > 30175 Hannover > Fax: +49 51184 48 98 99 > mailto:birke@kontor4.de > http://www.kontor4.de > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

Attachment: [application/pgp-signature]
« previous php.smarty.general (#11413) next »