TripleDES Posted May 30, 2007 Share Posted May 30, 2007 Is it possible to append to a temporary file? I'm iterating through a file and when a condition becomes true, I want to append the content to a temporary file. I want to display the contents once the loop completes. If there's a better suggestion on how to go about this, please let me know. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 30, 2007 Share Posted May 30, 2007 you mean like this ? <?php $somecontent = "blar"; if($a == "stuff") { $handle = fopen($filename, 'a') if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } fclose($handle); } ?> Quote Link to comment Share on other sites More sharing options...
TripleDES Posted May 30, 2007 Author Share Posted May 30, 2007 Silly me....I think so. So once you fclose(), the file goes bye bye unless you purposely write it?? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 30, 2007 Share Posted May 30, 2007 No Close tells the system you finished with the file.. to remove it use unlink($filename); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.