You are here: Re: Editing a (config) file « PHP Programming Language « IT news, forums, messages
Re: Editing a (config) file

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?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация