Link to home
Start Free TrialLog in
Avatar of go-fast
go-fast

asked on

Curl Currency Converter

I am looking for a currency converter using curl
ASKER CERTIFIED SOLUTION
Avatar of syedasimmeesaq
syedasimmeesaq
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
clean snipet below.
Hope it helps
<?php
function exchangeRate( $amount, $currency, $exchangeIn )
{
$googleQuery = $amount . ' ' . $currency . 'in '. $exchangeIn;
$googleQuery = urlEncode( $googleQuery );
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://www.google.com/search?q=' . $googleQuery);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
$file_contents = strip_tags( $file_contents );
curl_close($ch);
$matches = array();
preg_match( '/= (([0-9]|\.|,|\ )*)/', $file_contents, $matches );
return $matches[1] ? $matches[1] : false;
}
?>

Open in new window

No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
   Accept: syedasimmeesaq {http:#20816442}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

cyberwebservice
Experts Exchange Cleanup Volunteer
Forced accept.

Computer101
EE Admin