Reputation: 75
I am building a site that parses a spanish dictionary. If you look up the word HOLA, you will receive the definition, but for other words, you get suggestions, like CASA: http://verbum.xtrweb.com/verbumpost.php?word0=hola&word-1=casa
I wish to: when you click on the suggestions (like CASAR in the example I posted above) to print the result in a div like HOLA. Here is the code I am currently using:
$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>";
}
I am starting to code, so please be patient, I have also tried with some DOM code a friend suggested but it failed to function.
Upvotes: 1
Views: 124
Reputation: 846
to output content in a styled div, just replace:
echo "<div style='
//style
", (++$resultIndex) ,"'>", $contents,
"</div>";
}
with:
$divStyle = 'background: none repeat scroll 20% center transparent; margin-left: 275px; height: auto; box-shadow: 0px 0px 10px rgb(0, 0, 0) inset; border: 1px solid rgb(0, 0, 0); margin-top: 35px; padding-left: 14px; width: 793px; padding-bottom: 80px;';
//insert $divStyle as the "style" attribute
echo "<div style='" . $divStyle . "'" . (++$resultIndex) . "'>" . $contents . "</div>";
2 things changed:
Upvotes: 1