<?php
header('Access-Control-Allow-Origin: *');

$xml = @simplexml_load_file("https://www.tcmb.gov.tr/kurlar/today.xml");

if ($xml) {
    foreach ($xml->Currency as $currency) {
        if ($currency['Kod'] == 'USD') {
            $usdAlis = (float) str_replace(',', '.', $currency->ForexBuying);
            echo $usdAlis;
            exit;
        }
    }
}

echo "0"; // hata durumunda 