NO error received with regular expression
Any ideas how I can access the numeric value for the currency rate from the following XML tag:
<description>1 British Pound Sterling = 1.20409 Euro</description>
I require the numeric value 1.20409. Another problem will be the number 1 before British Pound.
My attempt so far:
function get_rate1(SimpleXMLElement $xml) {
$exchange['rate'] = $xml->channel->item[15]->description;
echo $exchange['rate'] . "<br />";
// Preg match regular expression to extract numbers
$imgpattern = "/^([0-9])$/";
preg_match($imgpattern, $exchange, $matches);
$exchange['rate'] = $matches[1];
echo $exchange['rate'] . ' /><br />';
return $rate;
}
Nothing is displayed with the above?
This post has been edited by NewToJava2011: 31 January 2012 - 01:09 PM

New Topic/Question
Reply



MultiQuote




|