Posted by Gulasch on 07/07/06 09:06
Sonnich schrieb:
> Hi
>
> I have a file with some configation in it... I am wondering how I
> correct single values in there.
>
> The most secure is to recreate the file, then rename it.
>
> But is there a way to correct a line in the text file?
> setting1=bla -> setting1=blablabla
>
> Needless to say, there are things in there I'd like to keep at all
> times.
>
> BR
> Sonnich
>
You could use preg_replace() (have a look at php.net).
For your Example it could be
--snip--
//Read the contents of the file into $file
$file=preg_replace("'setting1\=.*'", "setting1=blablabla", $file);
//Write $file back to the file.
--snap--
Or do I misunderstand your question?
[Back to original message]
|