Req #25334 [Com]: edit_ini_file() function would be nice

From: Date: Wed, 01 Sep 2021 18:52:47 +0000
Subject: Req #25334 [Com]: edit_ini_file() function would be nice
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236327@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=25334&edit=1 ID: 25334 Comment by: lildurk25334 at gmail dot com Reported by: php at richardneill dot org Summary: edit_ini_file() function would be nice Status: Wont fix Type: Feature/Change Request Package: PHP options/info functions Operating System: Linux (Mandrake 9.1) PHP Version: 4.3.1 Block user comment: N Private report: N New Comment: Lil Durk is a private agency dedicated to providing responsible access to legal cannabis for adults aged 19 and older. We’re an exclusively online retailer and wholesaler for recreational cannabis and a trusted source for information about cannabis and cannabis-related issues. We believe our work is meaningful and we take pride in our mandate to promote the socially responsible use of legal cannabis. https://lildurk.com/ Previous Comments: ------------------------------------------------------------------------ [2011-01-01 21:14:25] php at richardneill dot org Yes...but why re-write this so many times? Since this original report, I think I've implemented such a system at least 4 times in different ways, and it seems to be a really obvious candidate for a core library. It's also quite hard to handle the awkward cases, notably preserving comments. ------------------------------------------------------------------------ [2011-01-01 21:05:47] jani@php.net For something like this you have plenty of functions in PHP to implement it yourself in PHP code. ------------------------------------------------------------------------ [2003-08-31 19:25:30] php at richardneill dot org 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 this bug report at https://bugs.php.net/bug.php?id=25334&edit=1

« previous php.bugs (#236327) next »