Skip to content

Instantly share code, notes, and snippets.

@danieljpeter
Created May 4, 2012 00:38
Show Gist options
  • Save danieljpeter/2590723 to your computer and use it in GitHub Desktop.
Save danieljpeter/2590723 to your computer and use it in GitHub Desktop.
php search and replace
function searchReplaceBuildXmlFile($search, $replace) {
// Open file for read and string modification
$file = "/home/dpeter/sf/build.xml";
$fh = fopen($file, 'r');
$contents = fread($fh, filesize($file));
$new_contents = str_replace($search, $replace, $contents);
fclose($fh);
// Open file to write
$fh = fopen($file, 'w');
fwrite($fh, $new_contents);
fclose($fh);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment