| 
 Posted by Torgny Bjers on 09/27/05 17:01 
Chris wrote: 
> I'd like to save some program preferences to a txt file where they can be  
> recalled and updated at a later time. Basically this will be a variable name  
> and a value. Can someone suggest a reference or method to best perform this  
> task? 
>  
> Thanks 
> Chris 
> BTW: I do not want to use MySql.  
 
Write a regular Windows .ini file like: 
 
; My INI-file (this is a comment line): 
key = value 
key2 = value2 
; It even works with PHP constants (defines) in the ini file 
key3 = E_ALL 
 
Reading it in is simple, use parse_ini_file(): 
http://www.php.net/manual/en/function.parse-ini-file.php 
 
You can also keep sections in the .ini file such as: 
 
; a section name uses [] 
[section1] 
key = value 
[section2] 
key = value 
 
To write this down is easy, just do a foreach on your associative array 
and write to a string that you then save into a file if you wish to 
update the values here. 
 
Warm Regards, 
Torgny
 
[Back to original message] 
 |