<?php
function doviz_hesapla($total){




		$tcmbMirror = 'https://www.tcmb.gov.tr/kurlar/today.xml';
			 $curl = curl_init($tcmbMirror);
			 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
			 curl_setopt($curl, CURLOPT_URL, $tcmbMirror);

			 $dataFromtcmb = curl_exec($curl);

			  $Currencies = simplexml_load_string($dataFromtcmb);

				foreach($Currencies->Currency as $Currency) {
						$currency = $Currency->{'CurrencyName'};
						$currency_banknotebuying = $Currency->{'BanknoteBuying'};

						switch ($currency) {
								case 'US DOLLAR':
								$USD = substr(trim($currency_banknotebuying),0,4);
								$USD = number_format($USD,2);
								break;
								case 'EURO':
								$EUR = substr(trim($currency_banknotebuying),0,4);
								$EUR = number_format($EUR,2);
								break;
								case 'POUND STERLING':
								$POUND = substr(trim($currency_banknotebuying),0,4);
								$POUND = number_format($POUND,2);
								break;


						}
				}

    $POUND = number_format($POUND,2);
    $amount =   number_format($total, 2, '.', '');
	//echo  $amount*$POUND;
    return  $amount*$POUND;

}

//doviz_hesapla(1);
