Detect Browser Language

At the point when creating a multilingual site, I truly jump at the chance to recover the browser language and utilize this language as the default language for my site. Here's the way I get the language utilized by the client browser:

function get_client_language($availableLanguages, $default='en'){

  foreach ($langs as $value){
   if(in_array($choice, $availableLanguages)){
    return $choice;
 return $default;
Source :