editing ini files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Jasheppard
Forum Newbie
Posts: 24
Joined: Tue Jun 17, 2008 11:44 pm

editing ini files

Post 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?
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: editing ini files

Post by jayshields »

Why don't you want to use fopen()?
User avatar
Jasheppard
Forum Newbie
Posts: 24
Joined: Tue Jun 17, 2008 11:44 pm

Re: editing ini files

Post 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
Post Reply