0
オブジェクトから変数へのアクセスに問題があります。オブジェクトは、APIフィードから来ているとvar_dump
は次のようになります。simpleXMLから配列へのデータの再利用
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>"
}
私はグループのイベントの日付によると、その後、それらを注文することができるようにバック配列に入ってくる情報を並べ替えることができるようにしたいですイベント名別。私はそれが正常に見える$event->EventName;
をエコー場合
$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
);
}
が、私は、配列に追加しようとすると、それは次のように戻ってくる:以下は私のコードで私はここで間違ってやっている何
[EventName] => SimpleXMLElement Object
(
[0] => UMW Training Event
)
?
ta
、それは簡単なものになるだろう知っていました!本当にありがとう! – TH1981