Forum Moderators: coopster
[settings]
file_types = array("this","that");
...i also not you cant do:
time = date(formatted how i like it);
My old config.ini, accessed by scripts through require_once(), had arrays of options. Should I stick with this system, or is there something i should know about this parse_ini_file()?
Rgds
MAlcolm
parse_ini_file()myself yet, though I find it to be a pretty interesting function. Maybe someone who has used it already can give you some more pertinent advice than this, but anyways here's my understanding / guessing of things:
You can create a two-dimensional array like the one you want if you are willing to have [file_types] be a section -
[file_types]
1 = 'this'
2 = 'that'
date = DATENOW
DATENOWis a constant that your php script defined before it started parsing the ini file.
Ini files aren't php files, so that might be the simplest answer to your question 'why can't I'.
I guess I'd want to know, why do you want to change to an ini file? So it's easier to read for non-php people? Because it's easier to write to an ini file than a config file? If you want human - readable files that are also easy enough to write, you could try the PEAR xml - serialize class (will write an array to xml, and read an xml file into an array) - and there's a similar PHP function in PHP5. Only downside is that with the PEAR class it's likely to be a bit slower in execution than
parse_ini_file(), but then again, a straight config file will probably be the fastest when it comes to execution. The way-totally-hip-php-people these days are more interested in xml config files than ini files, I believe, so if you're after coolness points, it's got advantages, too.
If you just want to write to a plain config file, there's also a PEAR class that will do that for you too - the config [pear.php.net] class - and it doesn't only do normal php config files, it does xml and ini files too!