Advertisement
marcker

cotacao2.php

Oct 5th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. <?php
  2.  
  3. $arr = Array();
  4. $arr2 = Array("Compra: ", "Venda: ");
  5. $url = "http://www4.bcb.gov.br/pec/taxas/batch/taxas.asp?id=txdolar";
  6. $expRegular = "/[0-9],[0-9]{4}|[0-9],[0-9]{3}/";
  7.  
  8. $initCurl = curl_init($url);
  9. curl_setopt($initCurl, CURLOPT_HEADER, 0);
  10. curl_setopt($initCurl, CURLOPT_RETURNTRANSFER, 1);
  11. $resultado = curl_exec($initCurl);
  12.  
  13. preg_match_all($expRegular, $resultado, $arr);
  14.  
  15. for ($i = 0; $i < count($arr[0]); $i += 1) {
  16.   echo "<b>" . $arr2[$i] . "</b>" . $arr[0][$i] . "<br />";
  17. }
  18.  
  19. curl_close($initCurl);
  20.  
  21. // curl http://www4.bcb.gov.br/pec/taxas/batch/taxas.asp?id=txdolar | grep -oie [0-9],[0-9][0-9][0-9][0-9]
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement