<?php
function googleTran($text)
{
if (empty($text)) return "";
$wf = file_get_contents('http://fanyi.youdao.com/translate?&doctype=json&type=AUTO&i='.$text);
$info = json_decode($wf,true);
echo '<pre>';
// var_dump($info);
$fanyi = $info["translateResult"];
$return = $fanyi[0][0]["tgt"];
return $return;
}
$test = googleTran('举行“迎国庆”升国旗仪式');
var_dump($test);
来源:CSDN
作者:凌俊峰
链接:https://blog.csdn.net/qq_40592933/article/details/103686197