Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getCurrencyConversion($currency = 'USD'){
- $content = file_get_contents("http://br.financas.yahoo.com/q?s={$currency}BRL=X");
- preg_match('/<span id=\"yfs_p20_'. strtolower($currency) .'brl=x\">(.*)<\/span>/', $content, $matches, PREG_OFFSET_CAPTURE);
- preg_match('/<span id=\"yfs_b00_'. strtolower($currency) .'brl=x\">(.*)<\/span>/', $content, $matches2, PREG_OFFSET_CAPTURE);
- preg_match('/<span id=\"yfs_a00_'. strtolower($currency) .'brl=x\">(.*)<\/span>/', $content, $matches3, PREG_OFFSET_CAPTURE);
- $variation = substr($matches[0][0], 29, 29);
- $buyPrice = substr($matches2[0][0], 28, 9);
- $sellPrice = substr($matches3[0][0], 28, 9);
- $currencyVariation = preg_replace('/\)/', '', $variation);
- echo <<<CURRENCY
- <td><strong>{$currency}</strong></td>
- <td>$buyPrice</td>
- <td>$sellPrice</td>
- <td class="green"><strong>$currencyVariation</strong></td>
- CURRENCY;
- }
Advertisement
Add Comment
Please, Sign In to add comment