Re: Changing variables in a text file

From: Date: Tue, 25 Mar 2003 16:03:17 +0000
Subject: Re: Changing variables in a text file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-140970@lists.php.net to get a copy of this message
If you know what is suposed to be in the file you can simply build up a new file. If you don't know what is in there but only that you need to change this to that, use file functions and regexes. You might also consider using an array instead of plain variables, so your file will become $config['var1']="xxxx"; $config['var2']="aaaa"; $config['template']="blue"; $config['anothervar']="foo"; This will make updates easier, as you know you only need to write everything in $config. Luis Lebron wrote:
I have a text file with a series of project variables. For example $var1="xxxx"; $var2="aaaa"; $template="blue"; $anothervar="foo"; Let say I need to change $template="blue"; to $template="red";. How can I do that keeping the rest of the file intact? thanks, Luis


« previous php.general (#140970) next »