-1

following is my code for php curl where i get values of currency conversion.

$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, "http://free.currencyconverterapi.com/api/v5/convert?q=USD_PKR&compact=y" );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$response = curl_exec( $ch );
$json = json_decode($response, true);
print_r($json);

it gives me result

Array ( [USD_PKR] => Array ( [val] => 131.1098 ) )

I want to put 131.1098 into a variable where I will update a sql table query. Kindly advice

Poorna Senani Gamage
  • 1,246
  • 2
  • 19
  • 30
Salman Razak
  • 85
  • 1
  • 1
  • 8

1 Answers1

0
$number = $json['USD_PKR']['val'];
sietse85
  • 1,488
  • 1
  • 10
  • 26