Using PHP / Google Translate foreign language to english

Here is the code to utilize Google Translate to translate any text to English for free.
this function translates chinese to english
if you want to use this function, please write your own curl_post_content – it’s just a curl request using post method – i have my own curl_post_content which i can’t publish here.
the data that google returns doesn’t work well with json_decode function, we have to fix it a little bit, see the str_replace function here

function translate_to_english($text)
$obj =json_decode($response,true ); //true converts stdClass to associative array.
foreach($obj[0] as $v)
return trim($result);