1

希望您能够帮助我。

我尝试了很多不同的方法,但我无法解决这个问题。

我有一个里面有对象的数组:

    Array
(
[1] => CntProviderIncentiveResult Object
    (
        [_StartDate:protected] => 1356303600
        [_EndDate:protected] => 1356908400
        [_ProviderRoom:CntProviderIncentiveResult:private] => 1
        [_RoomName:CntProviderIncentiveResult:private] => Doble
        [_RoomCode:CntProviderIncentiveResult:private] => 2370
        [_PropertyCode:CntProviderIncentiveResult:private] => anglers
        [_Occupancy:CntProviderIncentiveResult:private] => 
        [_Currency:CntProviderIncentiveResult:private] => 
        [_AllocationGroup:CntProviderIncentiveResult:private] => 
        [_FreeSaleGroup:CntProviderIncentiveResult:private] => 
        [_StopSaleGroup:CntProviderIncentiveResult:private] => 
        [_ReleaseGroup:CntProviderIncentiveResult:private] => 
        [_MinStayGroup:CntProviderIncentiveResult:private] => 
        [_UpdateRequirement:CntProviderIncentiveResult:private] => 

) )

我尝试将其中一个对象分配给设置数组键的新数组:

$ConfirmRoom = $ConfirmRoomData[$roomKey];

$roomKey数组的键在哪里。(1, 20, 21)

在我验证是否做得很好之后:

if ($ConfirmRoom instanceof CntProviderIncentiveResult) {echo "OK";} 

但是新对象$ConfirmRoom总是空的。

你能让我看到光明吗?

4

2 回答 2

1

尝试var_dump($ConfirmRoom)入门。

另外,确保isset($ConfirmRoomData[$roomKey])大数组确实在$ConfirmRoomData.

这些只是一些基本的调试步骤,可能有助于解决您的问题。我的猜测$roomKey是没有正确定义。

于 2012-12-24T00:57:02.110 回答
1

最后我解决了:

foreach ($ConfirmRoomData as $key => $value) {
if (is_object ($value)) {
if ($key == $roomKey){
                                            $ConfirmRoom = $value;
}

} }

于 2012-12-24T13:16:57.983 回答