Page 1 of 1

editing ini files

Posted: Thu Jun 26, 2008 4:13 am
by Jasheppard
does anyone know how to edit .ini files in php? BY NOT USING fopen() ???

i can read ini files using parse_ini_file("test.ini",true); and set them to arrays but how can i edit a ini file?

it should be easy as reading it. isnt there a function to write an array into a ini file? because i have looked in many places and i cant seem to find a function to do so?

a part of my Ini file:

Code: Select all

 
[bob]
pass=house
auth=full
 
[god]
pass=tree
auth=full
 
What i use to read the data:

Code: Select all

 
$ini = parse_ini_file("test.ini",true);
echo "<br />Bobs password is: ".$ini["bob"]["pass"];
echo "<br />God's password is: ".$ini["god"]["pass"];
echo "<br />God's Membership is: ".$ini["god"]["auth"];
 
Now all i need and cant find how to is do the opposite, putting an array into a ini file.?

any ideas anyone?

Re: editing ini files

Posted: Thu Jun 26, 2008 5:23 am
by jayshields
Why don't you want to use fopen()?

Re: editing ini files

Posted: Thu Jun 26, 2008 5:35 am
by Jasheppard
because i need to be able to change a certain value of any user without knowing the line number...

i just confused myself?

i suppose i can use something like:
foreach user, write [name] then for each value, write valuename=string