我需要USD
通过代码“USD”或 ID“R01235”获取某种货币的价值
我尝试下一个,但它不是那么正确
<?php
$pattern = 'USD.*(\\d{2},\\d{4})';
$subject = '<Valute ID="R01215">
<NumCode>208</NumCode>
<CharCode>DKK</CharCode>
<Nominal>10</Nominal>
<Name>Danish kroner</Name>
<Value>57,4385</Value>
</Valute>
<Valute ID="R01235">
<NumCode>840</NumCode>
<CharCode>USD</CharCode>
<Nominal>1</Nominal>
<Name>U.S. dollar</Name>
<Value>33,2247</Value>
</Valute>
<Valute ID="R01239">
<NumCode>978</NumCode>
<CharCode>EUR</CharCode>
<Nominal>1</Nominal>
<Name>Euro</Name>
<Value>42,8399</Value>
</Valute>';
$result = preg_match( $pattern, $subject , $matches );
echo $result;
print_r($matches);
?>