Created
May 4, 2012 00:38
-
-
Save danieljpeter/2590723 to your computer and use it in GitHub Desktop.
php search and replace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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