currency convertor in php

Solutions on MaxInterview for currency convertor in php by the best coders in the world

showing results for - "currency convertor in php"
Kenza
11 Apr 2018
1<?php
2  /////for current update currency using api/////
3  $curl = curl_init();
4curl_setopt_array($curl, array(
5  CURLOPT_URL => "https://api.exchangeratesapi.io/latest?base=USD",
6  CURLOPT_RETURNTRANSFER => true,
7  CURLOPT_ENCODING => "",
8  CURLOPT_MAXREDIRS => 10,
9  CURLOPT_TIMEOUT => 30,
10  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
11  CURLOPT_CUSTOMREQUEST => "GET",
12  CURLOPT_POSTFIELDS => "{\n\t\"QuantityOnHand\":1,\n\t\"ReOrderPoint\":1,\n\t\"QuantityAsOfDate\":\"2018-03-01\"\n}",
13  CURLOPT_HTTPHEADER => array(
14    "cache-control: no-cache",
15    "postman-token: f8326c98-2bb7-a466-6f5e-cb8bfc5421d0"
16  ),
17));
18
19$response = curl_exec($curl);
20$err = curl_error($curl);
21
22curl_close($curl);
23
24if ($err) {
25  echo "cURL Error #:" . $err;
26} else {
27 $response;
28  $response= json_decode($response,true);
29 $CAD= $response['rates']['CAD'];
30 $AUD= $response['rates']['AUD'];
31   
32   $GBP= $response['rates']['GBP'];
33  
34 
35
36
37
38  // echo"<pre>";
39  // print_r($response);
40  // echo"</pre>";
41 
42?>