Here:
Code:
<?php
$fileContent = implode("", file("filename"));
//Replace a string
$fileContent = str_replace($old, $new, $fileContent);
//OR you can insert/delete a string at a specific point
//in the variable, do whatever processing you need.
$fp = fopen("filename", "w");
fputs($fp, $fileContent);
fclose($fp);
?>
If you want to add something to the end of a file:
Code:
<?php
$fp = fopen("filename", "a");
fputs($fp, "Whatever text");
fclose($fp);
?>
At the start of a file:
Code:
<?php
$fileContent = implode("", file("filename"));
$fileContent = "New Text" . $fileContent;
//Then just write to file using "w"
?>
HTH,
Jamal