Hello there -
this should give you a new file of that name with the text changes you wanted. I used str_replace to replace the text because it's so much faster than the others, but it is case sensitive. If that is a problem, you might look at preg_replace
Hope this helps you out! 🙂
<?php
$old_file = "/var/www/magazine/newstickerdata.xml";
$new_file = "/var/www/mypage/newstickerdata.xml";
// if you have PHP > 4.3.0 (I don't yet) use file_get_contents
// ex: $contents = file_get_contents($old_file) or die("Cannot get contents of $old_file");
// then you won't have to do an implode
if(!$file_array = file($old_file))
{
print "Cannot get contents of $old_file";
exit();
}
$contents = implode("", $file_array);
// do the replacements needed
$pattern = "<movie_width>750</movie_width>";
$replace = "<movie_width>430</movie_width>";
$contents = str_replace($pattern, $replace, $contents);
// try to open the new file and write the contents to it
$handle = fopen($new_file, "w+") or die("Cannot open $new_file");
fwrite($handle, $contents) or die("Cannot write to $new_file");
fclose($handle);
print "Done!";
?>