curlを使用してロシア語でutf-8のページを取得します。テキストをエコーすると、うまく表示されます。それから私はそのようなコードを使用します
$dom = new domDocument;
/*** load the html into the object ***/
@$dom->loadHTML($html);
/*** discard white space ***/
$dom->preserveWhiteSpace = false;
/*** the table by its tag name ***/
$tables = $dom->getElementsByTagName('table');
/*** get all rows from the table ***/
$rows = $tables->item(0)->getElementsByTagName('tr');
/*** loop over the table rows ***/
for ($i = 0; $i <= 5; $i++)
{
/*** get each column by tag name ***/
$cols = $rows->item($i)->getElementsByTagName('td');
echo $cols->item(2)->nodeValue;
echo '<hr />';
}
$htmlにはロシア語のテキストが含まれています。その後、echo $ cols-> item(2)-> nodeValue; ロシア語ではなく、エラーテキストを表示します。iconvを試しましたが、機能しません。何か案は?