我使用curl以俄语使用utf-8获取页面。如果我回显文字,它显示良好。然后我使用这样的代码与俄语语言的PHP问题
$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但不工作。有任何想法吗?
我不明白你的问题是什么。你会得到什么错误文字? “不起作用”是什么意思? – 2010-10-06 12:34:33
而不是俄语我得到了ÐÑоÑо? – kusanagi 2010-10-06 12:36:13