fork download
  1. <?php
  2. $url = "https://a...content-available-to-author-only...i.com/v4/latest/USD";
  3.  
  4. // curl ile API'yi çağır
  5. $ch = curl_init($url);
  6. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  7. $response = curl_exec($ch);
  8.  
  9. // JSON'u PHP dizisine çevir
  10. $data = json_decode($response, true);
  11.  
  12. // Euro ve TL kurunu al ve ortalama hesapla
  13. $eurRate = $data['rates']['EUR'];
  14. $tryRate = $data['rates']['TRY'];
  15. $averageRate = ($eurRate + $tryRate) / 2;
  16.  
  17. echo "USD - EUR Kuru: $eurRate\n";
  18. echo "USD - TRY Kuru: $tryRate\n";
  19. echo "Ortalama Kur: $averageRate\n";
  20. ?>
  21.  
Success #stdin #stdout 0.03s 26640KB
stdin
Standard input is empty
stdout
USD - EUR Kuru: 
USD - TRY Kuru: 
Ortalama Kur: 0