<?
$url = "http://www.nulled.ru";
$page = file_get_contents($url);
/* character set */
preg_match( '@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s+charset=([^\s"]+))?@i',
$page, $matches );
if ( isset( $matches[1] ) )
$mime = $matches[1];
if ( isset( $matches[3] ) )
$charset = $matches[3];
$search = array('@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments including CDATA
);
$content = substr(preg_replace($search, '', $page) ,0 ,200);
//or
//$content = substr(strip_tags($page) ,0 ,200);
$content_detect_language = urlencode(iconv($charset, "UTF-8", $content));
//powered by Google
$detect_language_url = "http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q=".$content_detect_language;
$json = file_get_contents($detect_language_url);
$object = json_decode($json,true);
echo $charset.', '.$object['responseData']['language'];
?>