设为首页 收藏本站
查看: 865|回复: 0

[经验分享] Euro foreign exchange reference rates

[复制链接]

尚未签到

发表于 2015-9-11 08:18:41 | 显示全部楼层 |阅读模式
  The reference rates are usually updated by 3 p.m. C.E.T. They are based on a regular daily concertation procedure between central banks across Europe and worldwide, which normally takes place at 2.15 p.m. CET.  
  How to parse the data
Regular expression example
<?php
//This is a PHP(4/5) script example on how eurofxref-daily.xml can be parsed
//Read eurofxref-daily.xml file in memory
//For this command you will need the config option allow_url_fopen=On (default)
$XMLContent=file(&quot;http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml&quot;);
//the file is updated daily between 2.15 p.m. and 3.00 p.m. CET
foreach($XMLContent as $line){
if(preg_match(&quot;/currency='([[:alpha:]]+)'/&quot;,$line,$currencyCode)){
if(preg_match(&quot;/rate='([[:graph:]]+)'/&quot;,$line,$rate)){
//Output the value of 1EUR 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
//--------------------------------------------------
}
}
}
?>
XML parser example
<?php
function StartElement($parser, $name, $attrs) {
if (!empty($attrs['RATE'])) {
echo &quot;1&euro;=&quot;.$attrs['RATE'].&quot; &quot;.$attrs['CURRENCY'].&quot;<br />&quot;;
}
}
$xml_parser= xml_parser_create();
xml_set_element_handler($xml_parser, &quot;StartElement&quot;, &quot;&quot;);
// for the following command you will need file_get_contents (PHP >= 4.3.0)
// and the config option allow_url_fopen=On (default)
xml_parse($xml_parser, file_get_contents (&quot;http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml&quot;));
xml_parser_free($xml_parser);
?>
SimpleXML example
<?php
//This is aPHP(5)script example on how eurofxref-daily.xml can be parsed
//Read eurofxref-daily.xml file in memory
//For the next command you will need the config option allow_url_fopen=On (default)
$XML=simplexml_load_file(&quot;http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml&quot;);
//the file is updated daily between 2.15 p.m. and 3.00 p.m. CET
foreach($XML->Cube->Cube->Cube as $rate){
//Output the value of 1EUR for a currency code
echo '1&euro;='.$rate[&quot;rate&quot;].' '.$rate[&quot;currency&quot;].'<br/>';
//--------------------------------------------------
//Here you can add your code for inserting
//$rate[&quot;rate&quot;] and $rate[&quot;currency&quot;] into your database
//--------------------------------------------------
}
?>
Output of the code above
1&#8364;=1.3857 USD
1&#8364;=111.87 JPY
1&#8364;=1.9558 BGN
1&#8364;=24.598 CZK
1&#8364;=7.4562 DKK
1&#8364;=15.6466 EEK
1&#8364;=0.86860 GBP
1&#8364;=271.76 HUF
1&#8364;=3.4528 LTL
1&#8364;=0.7097 LVL
1&#8364;=3.9820 PLN
1&#8364;=4.2663 RON
1&#8364;=9.3610 SEK
1&#8364;=1.3708 CHF
1&#8364;=8.1920 NOK
1&#8364;=7.3470 HRK
1&#8364;=42.7523 RUB
1&#8364;=1.9887 TRY
1&#8364;=1.4216 AUD
1&#8364;=2.3638 BRL
1&#8364;=1.4150 CAD
1&#8364;=9.2437 CNY
1&#8364;=10.7467 HKD
1&#8364;=12383.89 IDR
1&#8364;=61.5200 INR
1&#8364;=1557.90 KRW
1&#8364;=17.1544 MXN
1&#8364;=4.3090 MYR
1&#8364;=1.8280 NZD
1&#8364;=59.741 PHP
1&#8364;=1.7968 SGD
1&#8364;=41.509 THB
1&#8364;=9.6827 ZAR
  from:http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-112101-1-1.html 上篇帖子: 进入“我的网站”弹出相应的exchange提醒窗口 下篇帖子: 《转》90%使用WebDAV开发的Exchange邮件管理(三)——获取邮件
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表