Salacious Posted November 18, 2013 Share Posted November 18, 2013 (edited) I was surfing the net looking for a quick and dirty way to take a table with 3 headers, 1 footer and its contents are create a comma delimited CSV file. what I came across is the following: preg_match('/<table(>| [^>]*>)(.*?)<\/table( |>)/is',$this->raw('./PayrollReportTable.report'),$b); $table = $b[2]; preg_match_all('/<tr(>| [^>]*>)(.*?)<\/tr( |>)/is',$table,$b); $rows = $b[2]; foreach ($rows as $row){ preg_match_all('/<td(>| [^>]*>)(.*?)<\/td( |>)/is',$row,$b); $out[] = strip_tags(implode(',',$b[2])); } $out = implode("\n", $out); var_dump($out); Its almost what I need, accept this solution ommits the headers (I have three remember) and the footer (only one). And I am not very good with rejex, so I was curious if some one here could me implement the missing pieces (header and footer). I would be ever so greatful. If you know of a better, cleaner, simpler, easier way please do share I am willing to try anything but over all what I have is pretty much what I want it just needs the headers and the footer. It should be noted that the actual table being processed here comes from: $this->raw('./PayrollReportTable.report') Edited November 18, 2013 by Salacious 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.