douaipi3965 2013-12-03 12:39
浏览 57
已采纳

试图在C:\ wamp中获取非对象的属性...(访问对象数组值)

$result is

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
            [Rate] => stdClass Object
                (
                    [rateId] => STANDARD
                    [rateVersion] => 
                    [contractId] => 
                    [contractVersion] => 000
                    [allocationId] => IBE
                    [perPaxRateTypeSet] => 
                    [taxInclusiveInRateFlag] => 
                    [price] => 3499
                    [offerPrice] => 3499
                    [packageCost] => 0
                    [taxAmount] => 0
                    [luxuryTax] => 437.38
                    [serviceTax] => 216.24
                    [offerPercentageDiscount] => 0
                    [offerIdentifier] => 
                    [displayType] => 
                    [rateIdentifierType] => STANDARD
                    [rateIdTypeDesc] => STANDARD RATE
                    [conceptIdentifier] => ONLYROOM
                    [packageIdentifier] => 
                    [smartRate] => 
                    [roomGrid] => stdClass Object
                        (
                            [room] => Array
                                (
                                    [0] => stdClass Object
                                        (
                                            [roomNumber] => 1
                                            [roomType] => TWN
                                            [pricingType] =>  
                                            [numOfPax] => 1
                                            [numberOfAdults] => 1
                                            [numberOfChildren] => 0
                                            [numberOfJuniors] => 0
                                            [numOfPaxForWhichRateApplied] => 1
                                            [numOfpaxStaying] => 0
                                            [conceptId] => ONLYROOM
                                            [isAlternative] => 
                                            [packageCost] => 0
                                            [taxAmount] => 0
                                            [luxuryTax] => 437.38
                                            [serviceTax] => 216.24
                                            [dayWiseRate] => stdClass Object
                                                (
                                                    [forDay] => stdClass Object
                                                        (
                                                            [date] => 2013-12-20
                                                            [price] => 3499
                                                            [offerPrice] => 3499
                                                            [taxAmount] => 0
                                                            [luxuryTax] => 437.38
                                                            [serviceTax] => 216.24
                                                            [availability] => 42
                                                        )

                                                )

                                        )

                                    [1] => stdClass Object
                                        (
                                            [roomNumber] => 1
                                            [roomType] => STD
                                            [pricingType] =>  
                                            [numOfPax] => 1
                                            [numberOfAdults] => 1
                                            [numberOfChildren] => 0
                                            [numberOfJuniors] => 0
                                            [numOfPaxForWhichRateApplied] => 1
                                            [numOfpaxStaying] => 0
                                            [conceptId] => ONLYROOM
                                            [isAlternative] => 1
                                            [packageCost] => 0
                                            [taxAmount] => 0
                                            [luxuryTax] => 437.38
                                            [serviceTax] => 216.24
                                            [dayWiseRate] => stdClass Object
                                                (
                                                    [forDay] => stdClass Object
                                                        (
                                                            [date] => 2013-12-20
                                                            [price] => 3499
                                                            [offerPrice] => 3499
                                                            [taxAmount] => 0
                                                            [luxuryTax] => 437.38
                                                            [serviceTax] => 216.24
                                                            [availability] => 21
                                                        )

                                                )

                                        )

                                )

                        )

                    [policies] => stdClass Object
                        (
                            [policy] => Array
                                (
                                    [0] => stdClass Object
                                        (
                                            [policyType] => ADV
                                            [policyCode] => ADVIXW1001
                                        )

                                    [1] => stdClass Object
                                        (
                                            [policyType] => CAN
                                            [policyCode] => CNXIXW1002
                                        )

                                    [2] => stdClass Object
                                        (
                                            [policyType] => AMD
                                            [policyCode] => AMDIXW1002
                                        )

                                    [3] => stdClass Object
                                        (
                                            [policyType] => NOS
                                            [policyCode] => NSIXW1002
                                        )

                                    [4] => stdClass Object
                                        (
                                            [policyType] => CCP
                                            [policyCode] => CIOIXW1001
                                        )

                                )

                        )

                )

        )

)

i want to access [rateIdTypeDesc] => STANDARD RATE

what i tried

foreach ($result->searchAvailabilityResult->Rate as $item)
{

echo $item->rateIdTypeDesc; echo "<hr>";


}


Notice: Trying to get property of non-object in C:\wamp
  • 写回答

1条回答 默认 最新

  • dongma7796 2013-12-03 12:41
    关注
    foreach ($result->searchAvailabilityResult->Rate as $key=>$item) {
      if($key == 'rateIdTypeDesc'){
        echo $item;
      }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 基于52单片机的酒精浓度检测系统加继电器和sim800
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答