- urlencode: documentation ( source)
- explode: documentation ( source)
- sprintf: documentation ( source)
<?php
function Translate($word, $conversion = 'es_to_fr') {
$word = urlencode($word);
$arr_langs = explode('_to_', $conversion);
$url =
sprintf('http://translate.google.com/translate_a/t?client=t&text=%s&hl=%s&sl=s&tl=%s&ie=UTF-8&oe=UTF-8&multires=1&otf=1&pc=1&trs=1&ssel=3&tsel=6&sc=1', $word, $arr_langs[1], $arr_langs[0], $arr_langs[1]);
$name_fr = curl($url);
$name_fr = explode('"', $name_fr);
return $name_fr[1];
}
echo Translate("fiordo");