Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8251049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:06:45+00:00 2026-06-08T00:06:45+00:00

I need to put xml into array and then use join function to show

  • 0

I need to put xml into array and then use join function to show xml file
I extract already xml but don’t know how to use join function for this code.
Please help me to figure out this.
Here is xml code:

<ValCurs Date="06.07.2012" name="Ratele oficiale de schimb">
<Valute ID="47">
<NumCode>978</NumCode>
<CharCode>EUR</CharCode>
<Nominal>1</Nominal>
<Name>Euro</Name>
<Value>15.3051</Value>
</Valute>
<Valute ID="44">
<NumCode>840</NumCode>
<CharCode>USD</CharCode>
<Nominal>1</Nominal>
<Name>Dolar S.U.A.</Name>
<Value>12.2343</Value>

Function to extraxt xml :

function curs() {
  $date = date("d.m.Y");  
  $link = 'http://bnm.md/md/official_exchange_rates?get_xml=1&date='.$date; 
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $link);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $xml_array = curl_exec($ch);
  curl_close($ch);
  $xml_array = file_get_contents($link);

    $values = array();

 $curs = new SimpleXMLElement($xml_array);

 foreach($curs as $key => $value) {

    if (($value->CharCode) == 'USD') {

    $values .= $value->Name." - ".$value->Value.", ";
    }

    if (($value->CharCode) == 'EUR') {

        $values .= $value->Name." - ".$value->Value.", ";
    }
  }

  $value = str_replace(',', '.', $values);

   return $value;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:06:48+00:00Added an answer on June 8, 2026 at 12:06 am

    It is not overly clear what you are asking for, but if I gather it correctly you want to do something like this. Note you were mixing array and string logic for the variable $values.

    $values = array();
    $curs = new SimpleXMLElement($xml_array);
    
    foreach($curs as $key => $value) {
    
        if (($value->CharCode) == 'USD') {
    
            $values[] = $value->Name." - ".$value->Value;
        }
    
        if (($value->CharCode) == 'EUR') {
    
            $values[] = $value->Name." - ".$value->Value;
        }
    }
    
    $value = implode('.', $values);
    
    return $value;
    

    Note: I’m not sure on the usefulness of merging these strings with “.” i’d expect you’d be after something like \n.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to put a rather large xml file into another xml file. I
I need to put a reference to an XML-schema (xsd) into an XML-node. It
i have defined some strings in the strings.xml file. Now I need to put
I need to put several folders into artifact archive. Now I am doing it
I need to put one of my test cases into a pending state. I
I need to put 2 textures on the same Square, but it keeps crashing
I need to put a custom hover menu from http://www.addthis.com/help/toolbox , but Rails uses
I have an XML file that I have parsed and have put the information
I am using PHP to generate some XML. I need to put quotes in
I am using the following function in php to load an xml doc into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.