title: Converting HTML Table to a CSV automatically using PHP?
body: <p>I am just in need to convert a this html table automatically in csv using PHP.
  Can someone provide any idea how to do this?
  Thanks.</p>
  
  <pre><code>$table = '&lt;table border="1"&gt;
  &lt;tr&gt;
  &lt;th&gt;Header 1&lt;/th&gt;
  &lt;th&gt;Header 2&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;row 1, cell 1&lt;/td&gt;
  &lt;td&gt;row 1, cell 2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;row 2, cell 1&lt;/td&gt;
  &lt;td&gt;row 2, cell 2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;';
  </code></pre>
  
  <p>Guys, I just need <strong>$table</strong> to convert in only <strong>.csv</strong> file, which could be automatically generated using some PHP function. We can define path for that csv file to <strong>/test/home/path_to_csv</strong></p>