Hello.
I tried to read the values for euro and USD from the site of the Ro central bank, and when I display the result, it it not how it should be.
The code is:
it displays:
1 USD este 23621
1 EURO este 37155
it should display 1:
1 USD este 2,3621
1 EURO este 3,7155
with a comma ,
When I view the source code from http://www.bnro.ro/Ro/Info/ the value for USD/euro is with a comma (,). and I can't understand why my code displays it without the comma.
Can you help me?
Alexandru
I tried to read the values for euro and USD from the site of the Ro central bank, and when I display the result, it it not how it should be.
The code is:
| Code: |
| <?php
function cursvalutar($valuta) { $file = fopen("http://www.bnro.ro/Ro/Info/", "r"); $today = date("d-m-Y"); $numeValuta = array("Euro","Dolarul SUA"); while (!feof($file)){ $line = fgets($file, 1024); if (eregi('<TD class="bold">(.*)</TD>', $line, $out)) { $cursvalutar = each($out); while (list($key,$val) = each($numeValuta)){ if ($val == "Euro") { $euro = str_replace(',','',$cursvalutar[1]); } if ($val == "Dolarul SUA"){ $dolar = str_replace(',','',$cursvalutar[1]); } break; } } } fclose($file); if($valuta == "dolar") return $dolar; elseif($valuta == "euro") return $euro; else return false; } echo "1 USD este "; echo cursvalutar('dolar')."<br />"; echo "1 EURO este "; echo cursvalutar('euro'); ?> |
it displays:
1 USD este 23621
1 EURO este 37155
it should display 1:
1 USD este 2,3621
1 EURO este 3,7155
with a comma ,
When I view the source code from http://www.bnro.ro/Ro/Info/ the value for USD/euro is with a comma (,). and I can't understand why my code displays it without the comma.
Can you help me?
Alexandru
