Ver Mensaje Individual
  #2 (permalink)  
Antiguo 29/04/2010, 10:35
Death_Empire
 
Fecha de Ingreso: febrero-2010
Mensajes: 818
Antigüedad: 14 años, 2 meses
Puntos: 55
Respuesta: Conversor de monedas automático

si se puede con javascript o php pero tendrías que leer los valores de las divisas desde algún sitio que los actualice diariamente (http://www.ecb.europa.eu/ecb/html/index.es.html)

directamente del banco europeo, tienes que tomar el valor que te interesa limpiarlo y utilizarlo por ejemplo multiplicarlo por el precio en euros

Código PHP:
[B]How to parse the data[/B]

         [B]This is just an example[/B]

         
                                 <?php
//This is a PHP (4/5) script example on how eurofxref-daily.xml can be parsed 

//Read eurofxref-daily.xml file in memory 
$XMLContentfile("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml");
//the file is updated daily between 2.15 p.m. and 3.00 p.m. CET

foreach ($XMLContent as $line) {
        if (
ereg("currency='([[:alpha:]]+)'",$line,$currencyCode)) {
            if (
ereg("rate='([[:graph:]]+)'",$line,$rate)) {
                    
//Output the value of 1 EUR for a currency code 
                    
echo '1 &euro; = '.$rate[1].' '.$currencyCode[1].'<br />';
                    
//--------------------------------------------------
                    // Here you can add your code for inserting
                    // $rate[1] and $currencyCode[1] into your database
                    //--------------------------------------------------
            
}
        }
}
?>                           [B]Output of the code above[/B]

                      1 € = 1.3256 USD
1 € = 124.76 JPY
1 € = 1.9558 BGN
1  € = 25.540 CZK
1 € = 7.4421 DKK
1 € = 15.6466 EEK
1 € =  0.86785 GBP
1 € = 268.28 HUF
1 € = 3.4528 LTL
1 € = 0.7081 LVL
1  € = 3.9153 PLN
1 € = 4.1370 RON
1 € = 9.6267 SEK
1 € = 1.4348  CHF
1 € = 7.8430 NOK
1 € = 7.2460 HRK
1 € = 38.7577 RUB
1 € =  1.9673 TRY
1 € = 1.4272 AUD
1 € = 2.3044 BRL
1 € = 1.3292 CAD
1  € = 9.0484 CNY
1 € = 10.2936 HKD
1 € = 11948.32 IDR
1 € =  59.0090 INR
1 € = 1477.79 KRW
1 € = 16.2651 MXN
1 € = 4.2320  MYR
1 € = 1.8339 NZD
1 € = 59.186 PHP
1 € = 1.8145 SGD
1 € =  42.797 THB
1 € = 9.7596 ZAR

Última edición por Death_Empire; 29/04/2010 a las 10:46