0
對於我的生活,我無法弄清楚如何訪問這個數組的值。每個示例stdClass
對象都具有某種類型的值。如果我嘗試例如$obj->0->0->city;
,則出現錯誤。訪問API的數組元素
有人可以告訴我一個例子如何訪問[city] => toronto
甚至[date_created] => 2011-05-03 14:33:58
?
我也試過這個沒有運氣。
$object = $buy[1];
$title = $object->title[0];
echo "$title";
感謝
這就是API給我。
stdClass Object
(
[id] => 1
[name] => toronto
[date_modified] => 2011-03-08 13:07:10
[tax_rate_provincial] =>
)
<br/>
Array
(
[0] => stdClass Object
(
[0] => stdClass Object
(
[id] => 28131844
[full_date] => 20110506
[end_date] => 20110511
[city] => toronto
[saved] => 1651
[discount_percentage] => 52
[deal_option] => Array
(
[0] => stdClass Object
(
[id] => 2600
[title] =>
[date_modified] => 0000-00-00 00:00:00
[date_created] => 2011-05-03 14:33:58
[value] => 3150
[price] => 1499
[deal_id] => 28131844
[is_default] => 0
)
)
[options] =>
[option_quantity] =>
[option_remaining] =>
[purchase_limit] => 1
[gift_limit] => 0