...

View Full Version : Automatically Replace



Tony M
12-02-2010, 04:26 PM
I have an xml file, I want to replace every word that is "example1" and replace them with "example2". I do not want to edit the original file, I want to make a new file from it and this new file will have "example2" words (that replaced "example1") on it
(Any Suggestions Will be Helpfull) :thumbsup:

poyzn
12-02-2010, 04:36 PM
$file1 = file_get_contents('path/to/file1');
$file2 = preg_replace('/example1/m', 'example2', $file1);
file_put_contents('/path/to/file2', $file2);

Lamped
12-02-2010, 04:51 PM
I answered this, in full, with working code at: http://www.codingforums.com/showthread.php?t=210761

If it didn't do quite what you wanted, perhaps continue that thread? Otherwise people will just be reinventing the wheel.

Tony M
12-02-2010, 05:15 PM
I answered this, in full, with working code at: http://www.codingforums.com/showthread.php?t=210761

If it didn't do quite what you wanted, perhaps continue that thread? Otherwise people will just be reinventing the wheel.

Ok, You are right but I want another method, other that simple xml... I want it php :confused:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum