title: Appending to a HTML log file in PHP
body: <p>I am trying to append to a log file, using HTML tables format for each incident. However, there is one difficulty which I am not sure how to solve. Here's a static output of the HTML</p>
  
  <pre><code>&lt;table&gt;
    &lt;tr&gt;&lt;td&gt; .... &lt;/td&gt;
    &lt;/tr&gt;
  
   &lt;!-- new log entry should enter here --&gt;
  
    &lt;/table&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The question is how I can quickly insert log entries into the table quickly without messing up the HTML, preferably using the least amount of processing? I know I can load in the entire file, use a templating solution, and rewrite the file but that may be slow (the log files could grow fast quickly!).</p>
  
  <p>So I am looking for the usual open file for append, and somehow write after the last row, but before the  tag.</p>
  
  <p>Any suggestions?</p>
  
  <p>PS. I know most browser would render the HMTL if I leave out the  tag at the end, but I am curious to see if there could be an ideal solution.</p>