function napi_arfolyam()
{
$tegnapelott = date("Y-m-d", mktime()-169200);
$tegnap = date("Y-m-d", mktime()-84600);
$ma = date("Y-m-d");
$bdy = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
$bdy.= "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
$bdy.= "<soap:Body>";
$bdy.= "<GetCurrentExchangeRates xmlns=\"http://www.mnb.hu/webservices/\" />";
$bdy.= "</soap:Body>";
$bdy.= "</soap:Envelope>\r\n";
$req = "POST /arfolyamok.asmx HTTP/1.1\r\n";
$req.= "Host: www.mnb.hu\r\n";
$req.= "Connection: Close\r\n";
$req.= "Content-Type: text/xml; charset=utf-8\r\n";
$req.= "Content-Length: ".strlen($bdy)."\r\n";
$req.= "SOAPAction: \"http://www.mnb.hu/webservices/GetCurrentExchangeRates\"\r\n\r\n";
$fs = fsockopen("www.mnb.hu", 80);
fwrite($fs, $req.$bdy);
while (!feof($fs))
{
$s = fgets($fs);
$kiad.= "".$s."<br>";
}
fclose($fs);
$dattext=" Hiba";
if (strpos($kiad, $ma)) { $dattext=" MA"; }
if (strpos($kiad, $tegnap)) { $dattext=" TEGNAP"; }
if (strpos($kiad, $tegnapelott)) { $dattext=" TEGNAPELĹTT"; }
$kiad = strstr($kiad, "<?xml");
$kiad = str_replace("<Day date=\"".$ma."\">","<br />", $kiad);
$kiad = str_replace("<Day date=\"".$tegnap."\">","<br />", $kiad);
$kiad = str_replace("<Day date=\"".$tegnapelott."\">","<br />", $kiad);
$kiad = str_replace("<MNBCurrentExchangeRates>", "", $kiad);
$kiad = str_replace("</Day></MNBCurrentExchangeRates>", "", $kiad);
$kiad = str_replace("<Rate curr=", "", $kiad);
$kiad = str_replace("\">", "\" ", $kiad);
$kiad = str_replace("unit=\"1\"", " \"1\" ", $kiad);
$kiad = str_replace("unit=\"100\"", " \"100\" ", $kiad);
$kiad = str_replace("</Rate>", "<br />", $kiad);
$kiad = str_replace("\"", "", $kiad);
$mnb_arfolyam = "<pre><b>Napi (MNB) árfolyam:".$dattext."</b>\rDev. Egys. Ft.".$kiad."</pre>";
$tags=explode("<br />", $kiad);
$i=0;
foreach($tags as $key=>$val)
{
$nem=substr($val, 0, 3);
#AUD 1 132.11
$intags=explode(" ", $val);
$egys=explode(' ', $egys=substr($val, 4));
$arfolyam[$i][nem]=$nem;
$arfolyam[$i][egys]=$egys[0];
$arfolyam[$i][arf]=$intags[1];
$i++;
}
return $arfolyam;
}





