2017-02-11 60 views
1

上的成員函數getSubscriptionDetailType()我創建Authorize.net定期計費報告,我得到訂閱數組列表。Authorize.net PHP致命錯誤:調用數組

$subscriptions[] = $response->getSubscriptionDetails(); 

當我嘗試回聲內部數組值象下面這樣,我得到這個錯誤 「PHP致命錯誤:在陣列調用一個成員函數getSubscriptionDetailType()」

echo $subscriptions[0]->getSubscriptionDetailType()->id; 

我想的var_dump看看這是怎麼回事這個數組裏面..我得到這個結果

array(1) { 
 
    [0]=> 
 
    array(1) { 
 
    [0]=> 
 
    object(net\authorize\api\contract\v1\SubscriptionDetailType)#200 (16) { 
 
     ["id":"net\authorize\api\contract\v1\SubscriptionDetailType":private]=> 
 
     int(4362259) 
 
     ["name":"net\authorize\api\contract\v1\SubscriptionDetailType":private]=> 
 
     string(29) "MetroCare Dental Subscription" 
 
     ["status":"net\authorize\api\contract\v1\SubscriptionDetailType":private]=> 
 
     string(7) "expired" 
 
     ["createTimeStampUTC":"net\authorize\api\contract\v1\SubscriptionDetailType":private]=> 
 
     object(DateTime)#195 (3) { 
 
     ["date"]=> 
 
     string(26) "2017-02-06 17:02:50.287000" 
 
     ["timezone_type"]=> 
 
     int(3) 
 
     ["timezone"]=> 
 
     string(3) "UTC" 
 
     } 
 
     ["firstName":"net\authorize\api\contract\v1\SubscriptionDetailType":private]=> 
 
     string(5) "javed" 
 
     ["lastName":"net\authorize\api\contract\v1\SubscriptionDetailType":private]=> 
 
     string(5) "Malik" 
 
     ["totalOccurrences":"net\authorize\api\contract\v1\SubscriptionDetailType":private]=> 
 
     int(1) 
 
     ["pastOccurrences":"net\authorize\api\contract\v1\SubscriptionDetailType":private]=> 
 
     int(1) 
 
    } 
 
    } 
 
}

回答

3

var dump顯示訂閱詳細信息 - 對象位於另一個數組內的數組中。兩個數組包含一個元素(偏移0),因此這將是:

$response[0][0]->getSubscriptionDetails(); 
+0

啊,是的..我真的很沮喪,並沒有注意到......它的工作原理,感謝隊友 – Javid

相關問題