[snip] I have been trying to log some data to an xml file. Whta my problem is now is that the </root> tag needs to be either replaced (overwritten) or i need to get the data in before EOF-1. I have spend some time on the manual, but could not find out hoe exactly i should get the last row and then move one up again to log the stuff to the file. [/snip]
A couple of things occured to me, but I am not sure that they're desirable... With </root> being the last tag (does it occupy its own line?) you could (pseudo-code, not tested and certain to be incomplete)... while(!feof($theXMLLogFile)){ $theXMLLine = fgets($theXMLLogFile, 255); if($theXMLLine == "</root>"){ $theNewLogLine = "stuff you need to write \n </root>"; ereg_replace("</root>", "$theNewLogLine", $theXMLLogFile); } } Now, makes you read the file all the way through each time, but you could open the file for appending, (fopen with a+) which places the file pointer at the EOL. You can test this last line pointer to make sure it is </root> and do the replace... HTH! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php