如何在返回单个值的同时将Object数组转换为数组


how to convert Object array to array while single value returning

如何在返回单个值的同时将Object数组转换为数组,这是我得到的o/p,当我只得到一家酒店时,我如何将其转换为代码中显示的第0[0]值。当我在o/p找到一家酒店时,我在访问时遇到了问题。print_r($result); via foreach()

    stdClass Object
    (
        [cityId] => 000000000020
        [checkInDate] => 2013-12-20
        [checkOutDate] => 2013-12-21
        [customerId] => 
        [customerAccountType] => SH01
        [customerType] => 
        [currency] => INR
        [noOfRoomsRequested] => 1
        [searchAvailabilityResult] => stdClass Object
            (
                [hotelId] => IXW1
                [hotelName] => Ginger Jamshedpur
            )
   )

===what i want is ================================

       stdClass Object
        (
            [cityId] => 000000000020
            [checkInDate] => 2013-12-20
            [checkOutDate] => 2013-12-21
            [customerId] => 
            [customerAccountType] => SH01
            [customerType] => 
            [currency] => INR
            [noOfRoomsRequested] => 1
            [searchAvailabilityResult] => Array
                (
                      [0] => stdClass Object
                           (
                          [hotelId] => IXW1
                          [hotelName] => Ginger Jamshedpur
                           )
                )
       )

在单值的情况下

$result->searchAvailabilityResult = array($result->searchAvailabilityResult);

非常感谢#Maciej Sz

$result->searchAvailabilityResult=get_object_vars($result->earchAvailabilibilityResult);