function identify_tables($tables) {
$table_info=array();
foreach ($tables as $table_id => $table) {
$tabletags_start = $this->multi_strpos("<table.*>", $table);
$tabletags_end = $this->multi_strpos("</table>", $table);
if (count($tabletags_start)>2) {
print 'innerarrays '.count($tabletags_start).'<br>';
continue 1;
}
preg_match("|<table(.*)>|U", $table, $settings);
preg_match_all("'<tr[^>]*>.*?</tr>'si", strtolower($table), $rows);
$table_info[$table_id]["settings"] = $settings[1];
foreach ($rows[0] as $row_number => $row) {
preg_match("|<tr(.*)>|U", $row, $settings);
preg_match_all("'<td[^>]*>(.*)?</td>'U", strtolower($row), $fields);
$row_info[$row_number]["settings"] = $settings[1];
foreach ($fields[0] as $field_number => $field) {
preg_match("|<td(.*)>|U", $field, $settings);
$rowspan = '';$colspan = '';$width = '';$height = '';
if (strpos($settings[1],'rowspan')) {
preg_match("'rowspan=(.*) 'U", stripslashes($settings[1]), $rowspan);
$rowspan=$rowspan[1];
}
if (strpos($settings[1],'colspan')) {
preg_match("'colspan=(.*) 'U", stripslashes($settings[1]), $colspan);
$colspan=$colspan[1];
}
if (strpos($settings[1],'width')) {
preg_match("'width=(.*) 'U", stripslashes($settings[1]), $width);
$width=$width[1];
}
if (strpos($settings[1],'height')) {
preg_match("'height=(.*) 'U", stripslashes($settings[1]), $height);
$height=$height[1];
}
$field_info[$field_number]["settings"]["rowspan"] = $rowspan;
$field_info[$field_number]["settings"]["colspan"] = $colspan;
$field_info[$field_number]["settings"]["width"] = $width;
$field_info[$field_number]["settings"]["height"] = $height;
$field_info[$field_number]["content"] = $fields[1][$field_number];
}
$row_info[$row_number]["fields"]=$field_info;
}
$table_info[$table_id]["rows"] = $row_info;
}
return $table_info;
}
function get_tables($content) {
$tables=array();
preg_match_all("'<table[^>]*>(.*)</table>'s", strip_tags(strtolower($content), '<table><tr><td><img><a>'), $tables);
print_r($tables);
//print_r(strtolower($content));
exit;
$tabletags_start = $this->multi_strpos("<table.*>", $content);
$tabletags_end = $this->multi_strpos("</table>", $content);
$key=0;
$run=0;
while ($tabletags_start[$run]) {
$n=$key;
while (isset($tabletags_start[$n]) && ($tabletags_start[$n]<$tabletags_end[$key])) {
$n++;
}
$start = $tabletags_start[$key];
$end = $tabletags_end[$n];
$tmp_table = substr($content, $start, ($end-$start));
$tables[count($tables)] = $tmp_table.'</table>';
$key=$n;
$run++;
}
return $this->identify_tables($tables);
}