Value of an associative Array as an array index

From: Date: Sun, 05 Jan 2003 15:56:56 +0000
Subject: Value of an associative Array as an array index
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7020@lists.php.net to get a copy of this message
Hi smart(y) users Isn't it possibe to use a value of an associative array as an index for another array? I have the following: Script: ------------- $lang_ar = array( 'hello' => 'Hallo', 'yesno' => array( '0' => 'No', '1' => 'Yes' ); ); $result = array( 'ans1' => 0, 'ans2' => 1, ); $smarty->assign_by_ref('lang_ar', $lang_ar); $smarty->assign_by_ref('result', $result); ------------- Within the template I'd like to output "Yes" or "No" dependent on the value of the Smarty-Variable {$reult.ans1}. {$lang_ar.yesno.$result.ans1} does not work, because it's interpreted as $this->_tpl_vars['lang_ar']['yesno']['result']['ans1'] All other attempts ended up in Syntax-errors. In PHP it would look like this: $lang_ar['yesno'][$result['ans1']] Does anyone has an idea how to accomplish this without using if/then/else clauses? Otherwise it would be a nice feature for the next version... ;-) Thanks for your help James

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