Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function convertCurrency()
- {
- $amounts = 597;
- $from_currency='USD';
- $to_currency='INR';
- $url = 'https://www.google.co.za/search?q='.$amounts.'+' . $from_currency . '+to+' . $to_currency;
- $cSession = curl_init();
- curl_setopt($cSession, CURLOPT_URL, $url);
- curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($cSession, CURLOPT_SSL_VERIFYPEER, true);
- $buffer = curl_exec($cSession);
- curl_close($cSession);
- preg_match("/<div class=\"J7UKTe\">(.*)<\/div>/",$buffer, $matches);
- $matches = preg_replace("/[^0-9.]/", "", $matches[1]);
- $amount = round($matches, 2);
- $total = substr($amount, mb_strlen($amounts));
- return number_format($total,2);
- }
Add Comment
Please, Sign In to add comment