我的網站解析西班牙語字典,並允許您一次搜索多個單詞。如果你看到「hola」,你會得到第一個div)。有些話拿出建議,如 「卡薩」,而不是像 「HOLA」 的定義:如何打開在div中解析的鏈接?
什麼我期待的是這樣的:
所以,我希望:當您點擊建議(例如我發佈的示例中的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/>';
但它沒有工作,也不知道真的哪裏/如何使用它。
首先,+1純粹是因爲我喜歡這個概念。其次,也許你應該研究javascript或jQuery以及ajax這種交互式用戶體驗。 – 2013-04-10 00:35:08
@ francisco.preller感謝弗朗西斯科,但我只是開始編程ahaha。我不知道從哪裏開始解決這個問題,所以我期待着直接的迴應或者是一個例子。謝謝! – 2013-04-10 00:41:21