<?php
if ($_GET["view"] == "da") {
$html_in_site = file_get_contents('http://www.bnb.bg/bnb/rates.nsf/vWebRatesByMonthBG/$First');
$string = preg_replace('/<tr><td>/', "\n", strip_tags($html_in_site, '<tr>,<td>'));
$string = preg_replace('/<\/td><td>|<\/td><td align=right>|<\/td>/', "\t", $string);
$lines = preg_split("/\n/", $string);
foreach ($lines as $line){
if (!preg_match('/^ |<|^$|^a\{|^\*|^Източник|^Позовава/', $line)){
if (preg_match('/^Щат/', $line)){
$date = date("m.d.Y");
$expl = preg_split("/\t/", $line);
echo 'Обменни курсове на БНБ за '. $date .'<br>
<b>USD:</b> ' . $expl[3];
}}}
$usd = $_POST["usd"];
$count = $usd * $expl[3];
print "<br>
$usd долара - $count лева";
}
else {
print "
<form action='?view=da' method='post'>
<input name='usd' type='text'><br>
<input name='submit' type='submit' value='Сметни'>
</form>";
}
?>