You will want to read up on these functions:
fopen()
fwrite()
fread()
fclose()
<?php
$filename = 'test.xml';
$somecontent = "<tag>Add this to the file</tag>\n";
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
print "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (!fwrite($handle, $somecontent)) {
print "Cannot write to file ($filename)";
exit;
}
print "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
print "The file $filename is not writable";
}
?>
Here is a link to all of PHP's filesystem functions, some of which you may find useful, which I have not mentioned above
http://www.php.net/manual/en/ref.filesystem.php