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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:45:17+00:00 2026-06-02T20:45:17+00:00

I need to loop through the items as an array within the SimpleXMLElement Object

  • 0

I need to loop through the items as an array within the SimpleXMLElement Object below but cannot seem to access it using $order->order->order->items. I can access the delivery and billing addresses using the same format, ie. $order->order->order->delivery_address and expected to get to the items array in the same way. However, I get an empty SimpleXMLElement Object when I print_r($order->order->order->items)

SimpleXMLElement Object
(
    [order] => SimpleXMLElement Object
        (
            [id] => 860268
            [shopkeeper_orderno] => 1001
            [customer] => 797476
            [creationdate] => Apr 19 2012 10:36:38:100AM
            [reference] => k2koju45rmaqfl45n20xbkmq
            [net] => 1500
            [vat] => 17.5
            [status] => 0
            [isnew] => 1
            [deductions] => 0
            [postage] => 1
            [paymentmethod] => PayPal              
            [instructions] => SimpleXMLElement Object
                (
                )

            [errors] => SimpleXMLElement Object
                (
                )

            [kashflow_synch] => 0
            [order] => Array
                (
                    [0] => SimpleXMLElement Object
                        (
                            [billing_address] => SimpleXMLElement Object
                                (
                                    [0] => 

                                )

                        )

                    [1] => SimpleXMLElement Object
                        (
                            [delivery_address] => SimpleXMLElement Object
                                (
                                    [0] => 

                                )

                        )

                    [2] => SimpleXMLElement Object
                        (
                            [items] => Array
                                (
                                    [0] => SimpleXMLElement Object
                                        (
                                            [id] => 1285158
                                            [headerID] => 860268
                                            [productID] => 4867690
                                            [description] => TEST ORDERING PF NODES - Special Offer Price
                                            [net] => 1400
                                            [vat] => 0
                                            [qty] => 1
                                            [formID] => -1
                                        )

                                    [1] => SimpleXMLElement Object
                                        (
                                            [id] => 1285159
                                            [headerID] => 860268
                                            [productID] => 4959678
                                            [description] => Wedding dress
                                            [net] => 100
                                            [vat] => 17.5
                                            [qty] => 1
                                            [formID] => -1
                                        )

                                )

                        )

                )

            [postage_tax] => 0
            [dispatched] => 0
            [paybyotherid] => -1
            [ip] => 81.168.43.121   
            [wheredidyouhearid] => -1
        )

)
  • 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-02T20:45:18+00:00Added an answer on June 2, 2026 at 8:45 pm

    Using Dan Lees suggestion I tried SimpleXMLElement::children() and did the below which works

    foreach ($order->children() as $order) {
            foreach ($order->children() as $order_details) {
                foreach ($order_details->children() as $order_items) {
                    echo $order_items->id;
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to loop through a set of 2-dimensional array of hidden input fields
Okay so this is a bit complex but I need to loop through this
I have a loop of about 2000+ items I need to go through: for
I need to loop through each day of the week (monday tues...) and compare
i have the following code ..i need to loop through end of the file
my heading kinda explains the problem. I need to loop through multiple ul tags
I need to periodically loop through links in my PHP database to check whether
Here's what I need to do: 1) Loop through every cell in a worksheet
I have a foreach loop in jQuery going through each 'div.panel', I need to
I'm trying to create a function that will loop through an array of various

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.