Re: [SMARTY] Arrays in config-files
| From: | Martin Kloss | Date: | Thu, 23 Oct 2003 15:52:51 +0000 |
| Subject: | Re: [SMARTY] Arrays in config-files | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-10407@lists.php.net to get a copy of this message | ||
At 14:39 23.10.2003 +0200, you wrote:
I just want to know if anyone has a solution to make config-files work with associative arrays?Hi, here's how I do it (example) In a config file I have a config setting: contact_subjects = array("" => "Please select","comment" => "My Comment", "other" => "Some Other Stuff") Then the config file gets loaded somewhere: $smarty->config_load('myconfig.conf'); And the item gets selected and assigned using an eval function: $smarty->assign('subjects', eval_str($smarty->get_config_vars('contact_subjects'))); The eval function is to typecast the string into a php array: function eval_str ($str="") { // return evaluated php string
return eval('return('.$str.');');
}
That's how it works for me :-)
Martin.
Martin Kloss
martin.kloss@triquart.de
Technische Direktion
************************
Triquart Neue Medien
Bellealliancestr.17
20259 Hamburg
Germany
Tel.+49 (40)432 923-0
Fax +49 (40)432 923-23
www.triquart.de
www.triquart-humor.de
*************************
"Lingo objektorientiert"
Das Buch zum Autor jetzt bestellen unter:
http://www.amazon.de/exec/obidos/ASIN/3898422194/lingmmugd