Answer the question
In order to leave comments, you need to log in
Problem with encoding in Simple HTML DOM Parser?
Hello!
Faced an encoding issue when using PHP Simple HTML DOM Parser.
Extract html text from paragraphs using the innertext() function. The text may contain tags,
for example text1 or even a link somewhere
Well, now to the point, here is the code:
foreach ($html->find('div[class="text"] p') as $text) {
$fulltext .= iconv("Windows-1251", "UTF-8", $text->innertext());
}
Answer the question
In order to leave comments, you need to log in
Put all the content of the html page into a string variable, convert it to the desired encoding (UTF-8) and only then feed it into a simple html dom parser. That's what I've always done and never experienced any problems.
Vit Vit , Put all html page content in string variable
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question