Replacing a value in a flat file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bboymarko
Forum Newbie
Posts: 1
Joined: Mon Dec 14, 2009 5:10 am

Replacing a value in a flat file

Post 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.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Replacing a value in a flat file

Post by AbraCadaver »

If those are the only requirements, this should work:

Code: Select all

$text = str_replace("Language=$language", "Language=$nlanguage", $text);
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply