diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/HTMLParser.php | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/HTMLParser.php b/src/HTMLParser.php index 1345bc1..1223891 100644 --- a/src/HTMLParser.php +++ b/src/HTMLParser.php @@ -1215,7 +1215,12 @@ class HTMLParser */ public function _cleanExtraParagraphs(DOMDocument $article) { - foreach ($article->getElementsByTagName('p') as $paragraph) { + $paragraphs = $article->getElementsByTagName('p'); + $length = $paragraphs->length; + + for ($i = 0; $i < $length; $i++) { + $paragraph = $paragraphs->item($length - 1 - $i); + $imgCount = $paragraph->getElementsByTagName('img')->length; $embedCount = $paragraph->getElementsByTagName('embed')->length; $objectCount = $paragraph->getElementsByTagName('object')->length; |