Jump to content

Adding a line to the beggining of a file


speerross

Recommended Posts

I'm trying to add a string to the beggining of an xml file; I've tried the standard fopen, fwrite etc:

 

$c=1;
while ($c<=($filenum)) {

$xmlfile1 = "splits/".$basefilename."-".$c.".xml";
$handler = @fopen($dir."/$xmlfile1","r+");
fwrite($handler,$batchid);
fclose($handler);
$c++;

}

 

This works, but as it adds the line it deletes text already in the file (which I need to preserve). What is the best method to solve this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.