Jump to content

Can some one help me add some additional functionality


Salacious

Recommended Posts

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 by Salacious
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.