在前面用@调用PHP值


Call a PHP Value with @ in Front

如何调用前面有@的数组值,如@activePropertyCount[]

尝试使用echo$value[HotelList][@activePropertyCount];

有一个属性与数组关联,例如HotelSummary-如果是,我该如何调用它?

代码看起来像:

Array
(
[HotelListResponse] => Array
    (
        [customerSessionId] => 0ABAAABC-3DA4-3914-B842-7B403B905AF7
        [numberOfRoomsRequested] => 1
        [moreResultsAvailable] => 1
        [cacheKey] => 793da43:14b847b403b:-5a8d
        [cacheLocation] => 10.186.170.188:7300
        [cachedSupplierResponse] => Array
            (
                [@supplierCacheTolerance] => MED_ENHANCED
                [@cachedTime] => 0
                [@supplierRequestNum] => 931
                [@supplierResponseNum] => 20
                [@supplierResponseTime] => 1501
                [@candidatePreptime] => 314
                [@otherOverheadTime] => 53
                [@tpidUsed] => 5110
                [@matchedCurrency] => true
                [@matchedLocale] => true
            )

用引号括起数组键:

echo $value['HotelList']['@activePropertyCount'];

即使您不需要特殊字符,也应该这样做,因为否则PHP首先要查找一个常量,如果找不到,就会返回到字符串。虽然这在HotelList上有效,但在@activePropertyCount上无效,因为如果不加引号,@将是一个语法错误。