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 6122121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:51:44+00:00 2026-05-23T15:51:44+00:00

I have parsed my xml into array using xml2array.php. It gave array like Array(

  • 0

I have parsed my xml into array using xml2array.php.
It gave array like

Array(
 [HotelImage] => Array
 (
      [0] => Array
      (
      )

      [1] => Array
      (
      )

      [0_attr] => Array
      (
           [Type] => Bar/Lounge
           [URL] => http://images.gta-travel.com/HH/Images/SA/ELS/ELS-HOL1-11.jpg
      )

      [1_attr] => Array
      (
           [Type] => Lobby
           [URL] => http://images.gta-travel.com/HH/Images/SA/ELS/ELS-HOL1-8.jpg
      )

      [2] => Array
      (
      )

      [2_attr] => Array
      (
           [Type] => Exterior
           [URL] => http://images.gta-travel.com/HH/Images/SA/ELS/ELS-HOL1-1.jpg
      )

      [3] => Array
      (
      )

      [3_attr] => Array
      (
           [Type] => Recreational Facilities
           [URL] => http://images.gta-travel.com/HH/Images/SA/ELS/ELS-HOL1-12.jpg
      )

     )
)

how can i store all _attr key values in a separate array.

  • 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-05-23T15:51:44+00:00Added an answer on May 23, 2026 at 3:51 pm
    // this may cause a dereference error.. if it does just run array_keys
    // and stro it in a sperate var that is then passed to preg_grep
    $attrKeys = preg_grep('#\d+_attr#', array_keys($xmlArray));
    $attrKeys = array_flip($attrKeys);
    $attributes = array_intersect_key($xmlArray, $attrKeys);
    $tags = array_diff_key($xmlArray, $attributes);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some simple XML which I would like to parse into an array
I have parsed XML file into objects, in which each object has a 1:1
I have a thousands of data parsed from huge XML to be inserted into
I have an XML file which I'd like to parse into a non-XML (text)
I have parsed XML using both of the following two methods... Parsing the XmlDocument
I have become able to parse the xml url using TBXML parser. parsed data
basically i have parsed some data from XML into a NSMutableArray that is shared
I am using eval to create an associative array from php built in xml
I am presently using SAXParser with SAXParserFactory, and I have run into a problem
I have a XML file like this: <Document> <Tests> <Test> <Name>A</Name> <Value>1</Value> </Test> <Test>

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.