Php 如何在foreach中显示特定数组
使用Php 如何在foreach中显示特定数组,php,arrays,Php,Arrays,使用break在第一次匹配后停止循环: <?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>";
break
在第一次匹配后停止循环:
<?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>";
}
}
?>
foreach($XMLContent作为$line){
如果(preg_match(“/rate=”([[:graph:]+)”/”,$line,$rate)){
回显“$rate[1]
”;
打破
}
}
您的问题到底是什么?请提供一个例子。
foreach($XMLContent as $line){
if(preg_match("/rate='([[:graph:]]+)'/",$line,$rate)){
echo "$rate[1]<br>";
break;
}
}