function _background_process_ass_parse_table in Background Process 8
Same name and namespace in other branches
- 6 background_process_ass/background_process_ass.module \_background_process_ass_parse_table()
- 7.2 background_process_ass/background_process_ass.module \_background_process_ass_parse_table()
- 7 background_process_ass/background_process_ass.module \_background_process_ass_parse_table()
Implements to Converts an HTML table into an associative array.
1 call to _background_process_ass_parse_table()
- background_process_ass_get_server_status in background_process_ass/
background_process_ass.module - Get apache extended server status.
File
- background_process_ass/
background_process_ass.module, line 257 - Implements Background Process Ass Module. @todo Implement admin interface. @todo Fix runtime check of running process.
Code
function _background_process_ass_parse_table($html) {
// Find the table.
preg_match_all("/<table.*?>.*?<\\/[\\s]*table>/s", $html, $table_htmls);
$tables = [];
foreach ($table_htmls[0] as $table_html) {
// Get title for each row.
preg_match_all("/<th.*?>(.*?)<\\/[\\s]*th>/s", $table_html, $matches);
$row_headers = $matches[1];
// Iterate each row.
preg_match_all("/<tr.*?>(.*?)<\\/[\\s]*tr>/s", $table_html, $matches);
$table = [];
foreach ($matches[1] as $row_html) {
$row_html = preg_replace("/\r|\n/", '', $row_html);
preg_match_all("/<td.*?>(.*?)<\\/[\\s]*td>/", $row_html, $td_matches);
$row = [];
for ($i = 0; $i < count($td_matches[1]); $i++) {
$td = strip_tags(html_entity_decode($td_matches[1][$i]));
$i2 = isset($row_headers[$i]) ? $row_headers[$i] : $i;
$row[$i2] = $td;
}
if (count($row) > 0) {
$table[] = $row;
}
}
$tables[] = $table;
}
return $tables;
}