Revision: 9043
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 18, 2008 12:30 by iTony
Initial Code
function file_intersperse_contents($szFilename, $szInject, $szFind) {
// Check if file exist
if(file_exists($szFilename)) {
// If file exist
// Get the content
$szContent = file_get_contents($szFilename);
// Replace the text
$szReplace = str_replace($szFind, $szInject, $szContent);
// Open the file
$szFile = fopen($szFilename, 'w+');
// Write the text into it
$bWrite = fwrite($szFile, $szReplace);
if($bWrite) {
// If success, close file and return true
fclose($szFile);
return true;
}
// If failure, close file and return false
fclose($szFile);
return false;
}
else {
die('File' . $szFilename . 'does not exist!');
}
}
Initial URL
Initial Description
Initial Title
Change line in a file
Initial Tags
Initial Language
PHP