how can we get current exchange rate Indian money to usd?
anybody can help me?
thanks
Getting Current Currency Exchane Rate in PHP
Moderator: General Moderators
- volomike
- Forum Regular
- Posts: 633
- Joined: Wed Jan 16, 2008 9:04 am
- Location: Myrtle Beach, South Carolina, USA
Re: Getting Current Currency Exchane Rate in PHP
Use Curl to hit this URL:
http://www.google.com/search?hl=en&q=IN ... tnG=Search
Now, parse the result for '<h2 class="r">' up to '</h2>'. Next, run the result through strip_tags() and then parse further for the value you need.
If you don't need this to be 100% accurate, then I highly advise you to cache this value, say, every 4 to 12 hours, in shared memory on the server. This keeps Google off your scent and also speeds up your website.
http://www.google.com/search?hl=en&q=IN ... tnG=Search
Now, parse the result for '<h2 class="r">' up to '</h2>'. Next, run the result through strip_tags() and then parse further for the value you need.
Code: Select all
preg_match('@<h2 class="r">(.*?)</h2>@s',$sResult,$asMatches);
$sResult = strip_tags($asMatches[1]);
Re: Getting Current Currency Exchane Rate in PHP
Look up web services - I know there's a web service out there that is much cleaner than parsing a web page.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: Getting Current Currency Exchane Rate in PHP
Isn't this what the $ syntax is for? Just kidding...
Re: Getting Current Currency Exchane Rate in PHP
There's many far better ways that screenscraping Google..
for example:
http://download.finance.yahoo.com/d/quo ... s=EURGBP=X
...merry christmas
for example:
http://download.finance.yahoo.com/d/quo ... s=EURGBP=X
...merry christmas