我的网站解析一本西班牙语词典,让您一次搜索多个单词。如果你查找“hola”,你会得到第一个 div)。有些词提出了建议,例如“casa”,而不是“hola”之类的定义:
我正在寻找的是:
所以,我想:当您单击建议时(例如我发布的示例中的 CASAR)以将结果打印在像 HOLA 这样的 div 中。这是使用的代码:
$words = array('word0','word-1');
function url_decode($string){
return urldecode(utf8_decode($string));
}
$baseUrl = 'http://lema.rae.es/drae/srv/search?val=';
$cssReplace = <<<EOT
<style type="text/css">
// I changed the style
</style>
</head>
EOT;
$resultIndex = 0;
foreach($words as $word) {
if(!isset($_REQUEST[$word]))
continue;
$contents = file_get_contents($baseUrl . urldecode(utf8_decode($_REQUEST[$word])));
$contents = str_replace('</head>', $cssReplace, $contents);
$contents = preg_replace('/(search?[\d\w]+)/','http://lema.rae.es/drae/srv/search', $contents);
echo "<div style='
//style
", (++$resultIndex) ,"'>", $contents,
"</div>";
}
我试过:$contents .= '<a href="">' . $word . '</a><br/>';
但它没有用,我也不知道在哪里/如何使用它。