Page 1 of 1

Replacing a value in a flat file

Posted: Mon Dec 14, 2009 5:16 am
by bboymarko
Hi,
I haven't done much php before. Im using PHP 4.2
I have a file which looks like

[UserFile]
Password=202cb962ac59075b964b07152d234b70
Company=test
Account=rwe111
Language=polish
Partner=Customer

I would like to replace the language with Polish.

I have my two values
$language = polish
$nlanguage = english

I have hunted around for a solution but they seem to throw errors on the preg_match because of the Lanuage=polish.

Would anybody be able to point me in the right direction?

Thank you very much in advance.

Re: Replacing a value in a flat file

Posted: Mon Dec 14, 2009 8:44 am
by AbraCadaver
If those are the only requirements, this should work:

Code: Select all

$text = str_replace("Language=$language", "Language=$nlanguage", $text);