我通过调用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解决方案。
任何人都可以帮助我。
答案 0 :(得分:1)
这是我的优化解决方案
if(is_object($HotelRoomResponse)) {
$NewHotelRoomResponse[0] = $HotelRoomResponse;
$HotelRoomResponse = $NewHotelRoomResponse;
}