1
Я получаю массив/объект путем вызова 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>
)
)
Я хочу serailize второго объекта первого объекта, т.е. если мы получаем больше типов номеров
Как я могу сделать выше объекта нравится
[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>
)
)
)
Также проверьте вопрос здесь у меня не было никакого решения для PHP. Может кто-нибудь мне помочь.
код Запись будет хорошим началом ... –
использование [is_array] (http://php.net/manual/en/function.is-array.php) и [is_object] (http://php.net/manual/en/function.is-object.php), чтобы проверить, что вы хотите делать с данными, которые вы получаете и действуете соответственно. – bansi
Как вы строите ответ в своем API? –