PHP code example of mews / tcmb-doviz

1. Go to this page and download the library: Download mews/tcmb-doviz library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mews / tcmb-doviz example snippets


$currency = new \Mews\Tcmb\Currency('http://www.tcmb.gov.tr/kurlar/today.xml');

// Tümünü listeme:
$items = $currency->getItems();
foreach($items as $item) {
    echo $item->CurrencyCode . ' / ' . $item->CurrencyName . ': Alış: ' . $item->ForexBuying . ' - Satış: ' . $item->ForexBuying . '<br>';
}

// Bir kurun verisine erişim:
// USD alış:
echo $currency->getItem('USD')->ForexBuying;
// USD satış:
echo $currency->getItem('USD')->ForexSelling;

// Tüm parametrelerin dökümü:
var_dump($currency->getItem('USD'));