Hey
This is my first post here after being a member of CodingForums.com for a few years so hopefully im not breaking any rules for asking stupid questions or w/e. But, heres my question. I am trying to make a script that retrieves content from another site, so far every script that I have found doesnt work and it doesnt seem to be a very popular topic online, ive tried a good 10 or so serach term variations and only come up with a decent handful of non-working scripts. Here is one of the scripts that seemed most promising to me.
<?PHP
function translate($phrase, $type){
$fp = @fopen("http://translator.dictionary.com/fcgi/translate?lp=$type&text=".urlencode($phrase), "r");
if($fp){
while($in = fread($fp, 1024))
$reply .= $in;
fclose($fp);
if(ereg("<!-- resultListStart -->(.*)<!-- resultListEnd -->", $reply, $reg))
return trim($reg[1]);
else
return "Error : Could not find translation!";
}
return "Error : Could not connect to translate.dictionary.com!";
}
// translate a phrase from english to german
echo "First translation = ".translate("Having fun with PHP", "en_ge")."<br>\n";
?>
That is from the Zend tech site, so i figured it was a good script, but it doesnt work ( Actual Tutorial ) Also, I was wondering if this script could be modified to retrieve the first 5 bits of info from a multi rowed table, for example
<table>
<tr>
<td>Data1</td>
</tr>
<tr>
<td>Data2</td>
</tr>
<tr>
<td>Data3</td>
</tr>
<tr>
<td>Data4</td>
</tr>
<tr>
<td>Data5</td>
</tr>
<tr>
<td>Data6</td>
</tr>
</table>
How would you modify the script to only retrieve data1-data5 and output them seperately? Im hoping that someone here knows what to do cuz until a few days ago I didnt even know this could be done and ive yet to find a working example for me to learn from so any help is appreciated.
Thanks