I'm trying to make my function more versatile by removing hard coded data.function get_currency_rate($currencySource) {if (isset($currencySource)) {        $feed = $currencySource;    } else {        echo 'Feed not found.  Check URL';    }    if (!$feed) {        echo('Feed not found');    }    $xml = new SimpleXmlElement($feed);    $rate = get_rate($xml, 15); //EUR    if ($feed == 'http://themoneyconverter.com/rss-feed/USD/rss.xml') {        $rate = get_rate($xml, 16); //GBP    } else {        $rate = get_rate($xml, 56);  //USD    }}I would prefer to pass in the values 15, 16, 56 and the URL 'http://themoneyconverter.com/rss-feed/USD/rss.xml' rather than hard coding them into the function. Below is the get_rate function. // Get and return currency rate// Perform regular exp<b></b>ression to extrat numeric data// Split title string to extract currency title function get_rate(SimpleXMLElement $xml, $xmlTagPosition) {    $currency['rate'] = $xml->channel->item[$xmlTagPosition]->description;    preg_match('/([0-9]+\.[0-9]+)/', $currency['rate'], $matches);    $rate = $matches[0];    $title['rate'] = $xml->channel->item[$xmlTagPosition]->title;    $title = explode('/', $title['rate']);    $title = $title[0];    echo $rate . ' ' . $title . '<br />';}The feed URLs are set in my cityConfig.php script as below: // Feed URLs //$theMoneyConverter = 'http://themoneyconverter.com/rss-feed/';// Define arrays // $cities = array('London', 'New York', 'Paris');$currencyHeadings = array('London - 1 British Pound Sterling', 'New York - 1 US Dollar', 'Paris - 1 Euro');$currencySource = array($theMoneyConverter . 'GBP/rss.xml', $theMoneyConverter . 'USD/rss.xml', $theMoneyConverter . 'EUR/rss.xml');$currencyId = array(15, 16, 56); ?>Notice the $currencyId array values are the same as those hard coded into the get_currency_rate function. I tried passing in a second parameter for the $currencyId to no avail. Any ideas where I'm going wrong? I have tried the following:Added an argument onto the end of the feed URL's e.g. ?x=15 // for EURO feed?x=16 // for GBP feed?x=56 // for USD feedThese numbers correspond to the position of the  XML tag as an array from the feed URL's. $currencySource = array($theMoneyConverter . 'GBP/rss.xml?x=15', $theMoneyConverter . 'USD/rss.xml?x=16', $theMoneyConverter . 'EUR/rss.xml?x=56');I have edited the get_rate function to parse in the URL and the PHP query.  // Get and return currency rate// Perform regular expression to extrat numeric data// Split title string to extract currency title function get_rate(SimpleXMLElement $xml) {    $vars = parse_url($xml, PHP_URL_QUERY);    parse_str($vars);    echo x =  . $x;    //$x = 15;     $currency['rate'] = $xml->channel->item[$x]->description;    preg_match('/([0-9]+\.[0-9]+)/', $currency['rate'], $matches);    $rate = $matches[0];    $title['rate'] = $xml->channel->item[$x]->title;    $title = explode('/', $title['rate']);    $title = $title[0];    echo $rate . ' ' . $title . '<br />';}
Configuring a currency converter to get exchange rate feeds for for multiple currencies
php;xml;url;configuration;rss