如何檢索AB_ID中的ID和名稱?我不想在foreach中循環,因爲總會有一個結果,這似乎沒有必要。 (除非它是唯一的方法)。對象中的數組中的對象?我如何檢索數據?
這是PHP。
print_r($response); // gives data below. truncated.
QueryResult Object
(
[queryLocator] =>
[done] => 1
[records] => Array
(
[0] => stdClass Object
(
[Account_Name] => business_name
[Account] => account_no
[AB] => 12344567
[AB_more] => stdClass Object
(
[Id] => 123445
[Name] => Test 3
)
目前我在做什麼:
foreach($response as $key => $val) { $name = $val->Account_Name; #returns business_name $account = $val->Account; #returns account_no $ab = $val->AB; #returns 12344567 // nothing below seems to work $ab_id = $val->AB_more->Id $ab_id = $val->AB_more.Id $ab_id = $val->AB_more[0]->Id
謝謝!
'$ response'是什麼? –
$ name和$ account是否有效?或者您對這些有問題嗎?你可以var_dump($ val-> AB_more)? – Saturnix
我更新了,對不起。上面的數據是$ response的print_r –