<?php
function google_translate($api_key, $text, $from_lang, $to_lang){
        if (!empty($text)) {
        $link = "https://www.googleapis.com/language/translate/v2?key=$api_key&source=$from_lang&target=$to_lang&q=$text";
        $response = file_get_contents($link);
        $array = json_decode($response);
        $return = $array->data->translations[0]->translatedText;
        return $return;
        }
}
?>
