From:             php at richardneill dot org
Operating system: Linux (Mandrake 9.1)
PHP version:      4.3.1
PHP Bug Type:     Feature/Change Request
Bug description:  edit_ini_file() function would be nice

Description:
------------
Here's an idea that I think would be useful for a new function. I'd like a
way to have an editable equivalent of parse_ini_file(). Many Unix programs
have config files that can be edited *both* by hand, or automatically by
the program. It would be nice to be able to do this in php. 

Eg if the file myfile.dat contains something like this:
----------------------------
//This is a custom config or data file
$foo="bar"; #comment2
$wibble="bibble";  /*comment 3*/
$aaa=3;
----------------------------

Then, I might call the following in my script:

edit_ini_file (myfile.dat, SET $foo="baz", UNSET $wibble, SET $bbb=4)

And as a result, the file would be appropriately changed, without
modifying the comments. In this case it would become:

----------------------------
//This is a custom config/data file
$foo="baz"; #comment2
$wibble=false;  /*comment 3*/
$aaa=3
$bbb=4;
----------------------------


I'd suggest the function should be able to:

1)SET a variable (i.e. change it if it exists, otherwise, set it)
2)UNSET a variable
3)Add a comment (after a particular variable)
4)Change a comment.



If I can be of any assistance, please let me know. I hope you like the
idea. Thanks for PHP - I love it :-)


-- 
Edit bug report at http://bugs.php.net/?id=25334&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25334&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25334&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25334&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25334&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25334&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25334&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25334&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25334&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25334&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25334&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25334&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25334&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25334&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25334&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25334&r=gnused

Reply via email to