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

  • Home
  • SEARCH
  • 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 7194743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:26:06+00:00 2026-05-28T20:26:06+00:00

I’m having trouble accessing variable from an object. The object is coming from an

  • 0

I’m having trouble accessing variable from an object. The object is coming from an API feed and a var_dump looks like this:

object(stdClass)#2 (1) {
  ["GetBookingsResult"]=>
  string(189227) "<Bookings>
  <Data>
    <BookingDate>2012-01-06T00:00:00-06:00</BookingDate>
    <StartBookingDate>2012-01-06T00:00:00-06:00</StartBookingDate>
    <RoomDescription>Dorm A</RoomDescription>
    <TimeEventStart>2012-01-06T15:00:00-06:00</TimeEventStart>
    <TimeEventEnd>2012-01-07T00:00:00-06:00</TimeEventEnd>
    <GroupName>Family Retreat</GroupName>
    <EventName>Family Retreat</EventName>
    <SetupTypeDescription>(none)</SetupTypeDescription>
    <SetupCount>27</SetupCount>
    <ReservationID>1222</ReservationID>
    <EventCoordinator />
    <GroupID>12</GroupID>
    <VIP xml:space="preserve"> </VIP>
    <VIPEvent>false</VIPEvent>
    <ClosedAllDay>false</ClosedAllDay>
    <OpenTime>1900-01-01T00:00:00-06:00</OpenTime>
    <CloseTime>1900-01-01T00:00:00-06:00</CloseTime>
    <GroupTypeDescription>Religious - Conference</GroupTypeDescription>
    <EventTypeDescription>Retreat</EventTypeDescription>
    <Contact>Phyllis 0000000000</Contact>
    <AltContact />
    <BookingID>29512</BookingID>
    <TimeBookingStart>2012-01-06T15:00:00-06:00</TimeBookingStart>
    <TimeBookingEnd>2012-01-07T00:00:00-06:00</TimeBookingEnd>
    <GMTStartTime>2012-01-06T15:00:00-06:00</GMTStartTime>
    <GMTEndTime>2012-01-07T00:00:00-06:00</GMTEndTime>
    <BuildingCode>Asb</BuildingCode>
    <Building>Dormitory</Building>
    <RoomCode>ASB A</RoomCode>
    <Room>Dorm A</Room>
    <RoomID>181</RoomID>
    <BuildingID>20</BuildingID>
    <StatusID>1</StatusID>
    <StatusTypeID>-14</StatusTypeID>
    <EventTypeID>1</EventTypeID>
    <GroupTypeID>1</GroupTypeID>
    <DateAdded>2011-01-09T08:25:02.72-06:00</DateAdded>
    <AddedBy>B Jordan</AddedBy>
    <DateChanged>2012-01-08T08:34:23.2-06:00</DateChanged>
    <ChangedBy>J Smith</ChangedBy>
  </Data>

  <Data>
    <BookingDate>2012-01-06T00:00:00-06:00</BookingDate>
    <StartBookingDate>2012-01-06T00:00:00-06:00</StartBookingDate>
    <RoomDescription>Dorm A1</RoomDescription>
    <TimeEventStart>2012-01-06T15:00:00-06:00</TimeEventStart>
    <TimeEventEnd>2012-01-07T00:00:00-06:00</TimeEventEnd>
    <GroupName>Family Retreat</GroupName>
    <EventName>Family Retreat</EventName>
    <SetupTypeDescription>(none)</SetupTypeDescription>
    <SetupCount>27</SetupCount>
    <ReservationID>1222</ReservationID>
    <EventCoordinator />
    <GroupID>12</GroupID>
    <VIP xml:space="preserve"> </VIP>
    <VIPEvent>false</VIPEvent>
    <ClosedAllDay>false</ClosedAllDay>
    <OpenTime>1900-01-01T00:00:00-06:00</OpenTime>
    <CloseTime>1900-01-01T00:00:00-06:00</CloseTime>
    <GroupTypeDescription>Religious - Conference</GroupTypeDescription>
    <EventTypeDescription>Retreat</EventTypeDescription>
    <Contact>Phyllis 0000000000</Contact>
    <AltContact />
    <BookingID>29512</BookingID>
    <TimeBookingStart>2012-01-06T15:00:00-06:00</TimeBookingStart>
    <TimeBookingEnd>2012-01-07T00:00:00-06:00</TimeBookingEnd>
    <GMTStartTime>2012-01-06T15:00:00-06:00</GMTStartTime>
    <GMTEndTime>2012-01-07T00:00:00-06:00</GMTEndTime>
    <BuildingCode>Asb</BuildingCode>
    <Building>Dormitory</Building>
    <RoomCode>Asb A1</RoomCode>
    <Room>Dorm A1</Room>
    <RoomID>7</RoomID>
    <BuildingID>20</BuildingID>
    <StatusID>1</StatusID>
    <StatusTypeID>-14</StatusTypeID>
    <EventTypeID>1</EventTypeID>
    <GroupTypeID>1</GroupTypeID>
    <DateAdded>2011-01-09T08:25:02.72-06:00</DateAdded>
    <AddedBy>P Jordan</AddedBy>
    <DateChanged>2012-01-08T08:34:23.2-06:00</DateChanged>
    <ChangedBy>J Smith</ChangedBy>
  </Data>
</Bookings>"
}

I want to be able to reorder the info that comes back into an array so that I can group the events by date and then order them by EventName. Below is my code:

$xml = simplexml_load_string($result->GetBookingsResult);

$list='';
    foreach($xml as $event){
        $st_date = lvmDateFormat($event->TimeBookingStart,'name');//function reformats date
        $en_date = lvmDateFormat($event->TimeBookingEnd,'name');
        $name =  lvmDateFormat($event->TimeBookingStart,'cal');
        $ename = $event->EventName;
$events[lvmDateFormat($event->TimeBookingStart,'name')][$st_date] = array(
            'EventName' => $ename
            ,'Date' => $name
            ,'TimeEventStart' => $st_date
            ,'TimeEventEnd' => $en_date
        );
    }

If I echo out $event->EventName; it looks fine, but when I try to add it to an array it comes back like this:

 [EventName] => SimpleXMLElement Object
                (
                    [0] => UMW Training Event
                )

What am I doing wrong here?

Ta

  • 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-28T20:26:07+00:00Added an answer on May 28, 2026 at 8:26 pm

    When you echo an object, it is converted to a string. So it will appear (because SimpleXMLElement defines a __toString() method internally) like you want it to – but the type of the $event variable is still an object of type SimpleXMLElement.

    You can easily store it as a string in the array, if you cast it to a string. Try changing this line:

    $ename = $event->EventName;
    

    …to this:

    $ename = (string) $event->EventName;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
Does anyone know how can I replace this 2 symbol below from the string
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have some data like this: 1 2 3 4 5 9 2 6
I would like to count the length of a string with PHP. The string

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.