Skip to content

Commit c01f1ec

Browse files
committed
Remove <font> tags and &nbsp
1 parent 928bd03 commit c01f1ec

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.DS_Store
2-
*~
2+
*~
3+
damien_test.php

src/HTMLTable2JSON.php

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -220,22 +220,29 @@ public function tableToJSON($url, $firstColIsRowName = TRUE, $tableID = '', $ign
220220
$inner_len = $inner_pos_end - $inner_pos_start;
221221
$cell_name = substr($cell, $inner_pos_start, $inner_len);
222222
$cell_name = str_replace('"', '\"', $cell_name);
223+
$cell_name = str_replace('&nbsp;', '', $cell_name);
223224
$cell_name = str_replace('<br />', '', $cell_name);
224225
$cell_name = trim($cell_name);
225226
$link_start = stripos($cell_name, '<a href=\"');
226-
if (false === $link_start)
227-
$link = null;
228-
else {
229-
$link_start += + strlen('<a href=\"');
230-
$link_end = stripos($cell_name, '\">', $link_start);
231-
$link_len = $link_end - $link_start;
232-
$link = substr($cell_name, $link_start, $link_len);
233-
$link_start = stripos($cell_name, '</a>');
234-
$link_end += strlen('\">');
235-
$link_len = $link_start - $link_end;
236-
$cell_name = substr($cell_name, $link_end, $link_len);
237-
}
238-
227+
if (false === $link_start)
228+
$link = null;
229+
else {
230+
$link_start += + strlen('<a href=\"');
231+
$link_end = stripos($cell_name, '\">', $link_start);
232+
$link_len = $link_end - $link_start;
233+
$link = substr($cell_name, $link_start, $link_len);
234+
$link_start = stripos($cell_name, '</a>');
235+
$link_end += strlen('\">');
236+
$link_len = $link_start - $link_end;
237+
$cell_name = substr($cell_name, $link_end, $link_len);
238+
}
239+
$link_start = stripos($cell_name, '<font');
240+
if (false !== $link_start) {
241+
$link_start = stripos($cell_name, '\">', $link_start) + strlen('\">');
242+
$link_end = stripos($cell_name, '</font>', $link_start);
243+
$link_len = $link_end - $link_start;
244+
$cell_name = substr($cell_name, $link_start, $link_len);
245+
}
239246
$other_pos = stripos($cell, ' rowspan-');
240247
if (false === $other_pos)
241248
$spans_one = true;

0 commit comments

Comments
 (0)