I'm working on this code that when I try to execute it on http://www.secra.de don't works but if I use it on http://www.elektro-guttau.de/ it show the correct value, ISO-8859-1 I think the if(!empty()) is not working. Some1 know how do it works?
$url = "http://www.secra.de/";
$html = file_get_contents($url);
$doc = new DOMDocument();
$doc->loadHTML($html);
$items = $doc->getElementsByTagName("meta");
if ($items->length > 0) {
$info = $items->item(0)->getAttribute('content');
if (!empty($info)) {
$info = $items->item(0)->getAttribute('charset');
}
echo $info;
$array = array($info);
$split = explode('=', $info);
$encode = end($split);
echo $encode;
}