Reputation: 123
<?php
$XMLContent=file("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml");
foreach($XMLContent as $line){
if(preg_match("/rate='([[:graph:]]+)'/",$line,$rate)){
echo "$rate[1]<br>";
}
}
?>
but the result are displayed all,my question that displaying data in the first row
Upvotes: 0
Views: 57
Reputation: 780769
Use break
to stop the loop after the first match:
foreach($XMLContent as $line){
if(preg_match("/rate='([[:graph:]]+)'/",$line,$rate)){
echo "$rate[1]<br>";
break;
}
}
Upvotes: 1