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. Link to comment https://forums.phpfreaks.com/topic/53641-solved-append-to-a-temporary-file/ 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); } ?> Link to comment https://forums.phpfreaks.com/topic/53641-solved-append-to-a-temporary-file/#findComment-265166 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?? Link to comment https://forums.phpfreaks.com/topic/53641-solved-append-to-a-temporary-file/#findComment-265183 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); Link to comment https://forums.phpfreaks.com/topic/53641-solved-append-to-a-temporary-file/#findComment-265189 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.