如何格式化以下数组/对象


How do I format following array/object

我通过调用 api 来获取数组/对象

如果房间类型更多,我会得到这样的阵列

 [HotelRoomResponse] => Array
                (
                    [0] => stdClass Object
                        (
                            [rateCode] => 203735593
                            [rateDescription] => Mango Standard
                            [RoomType] => stdClass Object
                                (
                                    [@roomTypeId] => 766936
                                    [@roomCode] => 200163941
                                    [description] => Mango Standard
                                    [descriptionLong] => <strong><ul><li>One Twin Bed</li></ul></strong>This city view room measures 247 square feet (23 square meters). Complimentary wireless Internet access keeps you connected, and the 26-inch flat-screen TV offers cable channels. A coffee/tea maker is provided. The private bathroom has a shower with a rainfall showerhead, as well as complimentary toiletries. Climate control, air conditioning, and a ceiling fan are among the conveniences offered.  <p></p>
                                 )
                           )
                      [1] => stdClass Object
                        (
                        [rateCode] => 200928482
                        [rateDescription] => Mango Standard
                        [RoomType] => stdClass Object
                            (
                                [@roomTypeId] => 766936
                                [@roomCode] => 200163941
                                [description] => Mango Standard
                                [descriptionLong] => <strong><ul><li>One Twin Bed</li></ul></strong>This city view room measures 247 square feet (23 square meters). Complimentary wireless Internet access keeps you connected, and the 26-inch flat-screen TV offers cable channels. A coffee/tea maker is provided. The private bathroom has a shower with a rainfall showerhead, as well as complimentary toiletries. Climate control, air conditioning, and a ceiling fan are among the conveniences offered.  <p></p>
                             )
                        )
                )

如果房间类型只有一种,我得到以下对象

  [HotelRoomResponse] => stdClass Object
                    (
                        [rateCode] => 1273814
                        [rateDescription] => Deluxe Double Room
                        [RoomType] => stdClass Object
                            (
                                [@roomTypeId] => 488629
                                [@roomCode] => 379721
                                [description] => Deluxe Double Room
                                [descriptionLong] => <strong><ul><li>2 beds</li></ul></strong>
                              )
                      )

我想将第二个对象分离为第一个对象,即如果我们获得更多的房间类型

我怎样才能使上面的对象像这样

 [HotelRoomResponse] => Array
                  (
                     [0] =>stdClass Object
                       (
                        [rateCode] => 1273814
                        [rateDescription] => Deluxe Double Room
                        [RoomType] => stdClass Object
                            (
                                [@roomTypeId] => 488629
                                [@roomCode] => 379721
                                [description] => Deluxe Double Room
                                [descriptionLong] => <strong><ul><li>2 beds</li></ul></strong>
                              )
                      )
                   ) 

还要检查这里的问题http://developer.ean.com/docs/error-handling/special-cases/axis-net-json-issues/我没有针对 PHP 的任何解决方案。谁能帮我。

这是我优化的解决方案

if(is_object($HotelRoomResponse)) {
    $NewHotelRoomResponse[0] = $HotelRoomResponse;
    $HotelRoomResponse = $NewHotelRoomResponse;
}